public code v1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>flintstones.group</groupId>
|
||||
<artifactId>flintstones.bundles</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>flintstones.method.decision.common.phase.selection.ui</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Ui</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.decision.common.phase.selection.ui</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1779484362661</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,33 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ui
|
||||
Bundle-SymbolicName: flintstones.method.decision.common.phase.selection.ui;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Require-Bundle: flintstones.method.decision.common.phase.selection,
|
||||
org.eclipse.swt,
|
||||
flintstones.entity.problemelement,
|
||||
javax.inject,
|
||||
flintstones.valuation.twoTuple,
|
||||
org.eclipse.jface,
|
||||
flintstones.domain.fuzzyset.ui.dialog,
|
||||
org.eclipse.e4.core.contexts,
|
||||
org.eclipse.e4.core.services,
|
||||
flintstones.helper.ui,
|
||||
flintstones.model.problemelement.service,
|
||||
de.kupzog.ktable,
|
||||
org.eclipse.e4.core.di,
|
||||
flintstones.entity.domain,
|
||||
flintstones.entity.valuation,
|
||||
flintstones.model.domain.ui.service,
|
||||
flintstones.entity.domain.ui.chart,
|
||||
flintstones.model.ui.service,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.entity.method.phase.ui,
|
||||
org.jfree.chart.jfreechart,
|
||||
flintstones.domain.fuzzyset.ui.chart,
|
||||
flintstones.helper.data,
|
||||
org.eclipse.nebula.widgets.opal.notifier,
|
||||
org.eclipse.e4.ui.model.workbench;bundle-version="2.1.0.v20180429-1333"
|
||||
Automatic-Module-Name: flintstones.method.decision.common.phase.selection.ui
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Export-Package: flintstones.method.decision.common.phase.selection.ui.handler
|
||||
@@ -0,0 +1,5 @@
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
source.. = src/
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin>
|
||||
|
||||
<extension
|
||||
point="flintstones.phasemethod.ui">
|
||||
<phasemethod_ui
|
||||
uid="flintstones.method.decision.common.phase.selection.ui.CalculateWeights"
|
||||
implementation="flintstones.method.decision.common.phase.selection.ui.CalculateWeightsUI"
|
||||
phasemethod="flintstones.method.decision.common.phase.selection.CalculateWeights">
|
||||
</phasemethod_ui>
|
||||
<phasemethod_ui
|
||||
uid="flintstones.method.decision.common.phase.selection.ui.CalculateDistances"
|
||||
implementation="flintstones.method.decision.common.phase.selection.ui.CalculateDistancesUI"
|
||||
phasemethod="flintstones.method.decision.common.phase.selection.CalculateDistances">
|
||||
</phasemethod_ui>
|
||||
<phasemethod_ui
|
||||
uid="flintstones.method.decision.common.phase.selection.ui.CalculateSolutions"
|
||||
implementation="flintstones.method.decision.common.phase.selection.ui.CalculateSolutionsSelectionUI"
|
||||
phasemethod="flintstones.method.decision.common.phase.selection.CalculateSolutions">
|
||||
</phasemethod_ui>
|
||||
</extension>
|
||||
<extension
|
||||
id="flintstones.method.decision.common.phase.selection.ui.fragment"
|
||||
point="org.eclipse.e4.workbench.model">
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+517
@@ -0,0 +1,517 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.jface.viewers.ColumnLabelProvider;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.viewers.TableViewerColumn;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
|
||||
import flintstones.domain.fuzzyset.FuzzySet;
|
||||
import flintstones.entity.domain.ui.chart.DomainChart;
|
||||
import flintstones.entity.method.phase.ui.PhaseMethodUI;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.method.decision.common.phase.selection.CalculateDistancesSelectionModel;
|
||||
import flintstones.method.decision.common.phase.selection.ui.messages.Messages;
|
||||
import flintstones.method.decision.common.phase.selection.ui.provider.ClosenessCoefficientsTableViewerContentProvider;
|
||||
import flintstones.method.decision.common.phase.selection.ui.provider.PositiveNegativeTableViewerContentProvider;
|
||||
import flintstones.model.domain.ui.service.IDomainUIService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
import flintstones.valuation.twoTuple.TwoTupleValuation;
|
||||
|
||||
public class CalculateDistancesUI extends PhaseMethodUI {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
IDomainUIService uiDomainService;
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemElementService;
|
||||
|
||||
// FS3
|
||||
private Composite parent;
|
||||
private Composite informationPanel;
|
||||
private Composite distanceEditorPanel;
|
||||
private Composite chartView;
|
||||
|
||||
private Combo retranslationCombo;
|
||||
|
||||
private TableViewer tableViewerPositiveNegative;
|
||||
private TableViewer tableViewerClosenessCoefficients; // X
|
||||
|
||||
private ControlAdapter controlListener;
|
||||
|
||||
private PositiveNegativeTableViewerContentProvider positiveNegativeProvider;
|
||||
private ClosenessCoefficientsTableViewerContentProvider closenessCoefficientsProvider;
|
||||
|
||||
private DomainChart chart;
|
||||
|
||||
CalculateDistancesSelectionModel model;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
Messages messages;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
model = (CalculateDistancesSelectionModel) this.getModel();
|
||||
createPartControl(this.getBaseComposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
model.execute();
|
||||
setInputDistancesTable();
|
||||
setInputCoefficientsTable();
|
||||
refreshChart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForwardEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class DataComparator implements Comparator<Object[]> {
|
||||
public int compare(Object[] d1, Object[] d2) {
|
||||
Alternative a1 = (Alternative) d1[0];
|
||||
Alternative a2 = (Alternative) d2[0];
|
||||
return a1.compareTo(a2);
|
||||
}
|
||||
}
|
||||
|
||||
public void createPartControl(Composite parent) {
|
||||
model.execute();
|
||||
|
||||
this.parent = parent;
|
||||
|
||||
UiService.setGridData(this.parent, 9, 9, true, true);
|
||||
GridLayout layout = UiService.setGridLayout(this.parent, 1, true);
|
||||
layout.horizontalSpacing = 15;
|
||||
layout.verticalSpacing = 15;
|
||||
|
||||
createContent();
|
||||
}
|
||||
|
||||
private void createContent() {
|
||||
distanceEditorPanel = new Composite(parent, SWT.NONE);
|
||||
|
||||
GridLayout ratingEditorPanelLayout = UiService.setGridLayout(distanceEditorPanel, 1, false);
|
||||
ratingEditorPanelLayout.marginRight = 0;
|
||||
ratingEditorPanelLayout.verticalSpacing = 0;
|
||||
ratingEditorPanelLayout.marginWidth = 10;
|
||||
ratingEditorPanelLayout.marginHeight = 10;
|
||||
UiService.setGridData(distanceEditorPanel, 9, 9, true, true);
|
||||
|
||||
GridLayout informationLayout = new GridLayout(2, true);
|
||||
informationLayout.marginWidth = 10;
|
||||
informationLayout.marginHeight = 10;
|
||||
|
||||
informationPanel = new Composite(distanceEditorPanel, SWT.NONE);
|
||||
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
|
||||
informationPanel.setLayoutData(gridData);
|
||||
informationPanel.setLayout(informationLayout);
|
||||
|
||||
createDistancesTable();
|
||||
createClosenessCoefficientsTable();
|
||||
createChart();
|
||||
createRetranslationCombo();
|
||||
setSensitivityAnalysisData();
|
||||
}
|
||||
|
||||
private void createDistancesTable() {
|
||||
GridLayout positiveNegativeLayout = new GridLayout(1, true);
|
||||
positiveNegativeLayout.marginWidth = 10;
|
||||
positiveNegativeLayout.marginHeight = 10;
|
||||
|
||||
Composite positveNegativePanel = new Composite(informationPanel, SWT.NONE);
|
||||
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
|
||||
positveNegativePanel.setLayoutData(gridData);
|
||||
positveNegativePanel.setLayout(positiveNegativeLayout);
|
||||
|
||||
Label positiveNegativeLabel = new Label(positveNegativePanel, SWT.NONE);
|
||||
positiveNegativeLabel.setText(messages.CalculateDistances_Ideal_solution);
|
||||
UiService.setFont(positiveNegativeLabel, UiService.FONT_TEXT_BOLD);
|
||||
gridData = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
|
||||
positiveNegativeLabel.setLayoutData(gridData);
|
||||
|
||||
tableViewerPositiveNegative = new TableViewer(positveNegativePanel, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
|
||||
tableViewerPositiveNegative.getTable().setLayoutData(gridData);
|
||||
tableViewerPositiveNegative.getTable().setHeaderVisible(true);
|
||||
|
||||
positiveNegativeProvider = new PositiveNegativeTableViewerContentProvider();
|
||||
tableViewerPositiveNegative.setContentProvider(positiveNegativeProvider);
|
||||
|
||||
TableViewerColumn alternativeColumn = new TableViewerColumn(tableViewerPositiveNegative, SWT.NONE);
|
||||
alternativeColumn.getColumn().setText(messages.CalculateDistances_Alternative);
|
||||
alternativeColumn.getColumn().pack();
|
||||
alternativeColumn.getColumn().setResizable(false);
|
||||
alternativeColumn.getColumn().setMoveable(false);
|
||||
alternativeColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
return ((Alternative) data[0]).getName();
|
||||
}
|
||||
});
|
||||
|
||||
TableViewerColumn positiveColumn = new TableViewerColumn(tableViewerPositiveNegative, SWT.NONE);
|
||||
positiveColumn.getColumn().setText(messages.CalculateDistances_Positive_distance);
|
||||
positiveColumn.getColumn().setResizable(false);
|
||||
positiveColumn.getColumn().setMoveable(false);
|
||||
positiveColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
TwoTupleValuation distance = (TwoTupleValuation) data[1];
|
||||
|
||||
String labelName = distance.getLabel().getName();
|
||||
String alpha = Double.toString(distance.getAlpha());
|
||||
|
||||
if(alpha.equals("-0.0") || alpha.equals("0.0")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
alpha = "0"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
int size = 4;
|
||||
if(alpha.startsWith("-")) { //$NON-NLS-1$
|
||||
size = 5;
|
||||
}
|
||||
|
||||
if(alpha.length() > size) {
|
||||
alpha = alpha.substring(0, size);
|
||||
}
|
||||
|
||||
if(alpha.length() > 1) {
|
||||
if(alpha.endsWith("0")) { //$NON-NLS-1$
|
||||
alpha = alpha.substring(0, size - 1);
|
||||
}
|
||||
}
|
||||
return "(" + labelName + ", " + alpha + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
});
|
||||
|
||||
TableViewerColumn negativeColumn = new TableViewerColumn(tableViewerPositiveNegative, SWT.NONE);
|
||||
negativeColumn.getColumn().setText(messages.CalculateDistances_Negative_distance);
|
||||
negativeColumn.getColumn().setResizable(false);
|
||||
negativeColumn.getColumn().setMoveable(false);
|
||||
negativeColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
TwoTupleValuation distance = (TwoTupleValuation) data[2];
|
||||
|
||||
String labelName = distance.getLabel().getName();
|
||||
String alpha = Double.toString(distance.getAlpha());
|
||||
|
||||
if(alpha.equals("-0.0") || alpha.equals("0.0")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
alpha = "0"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
int size = 4;
|
||||
if(alpha.startsWith("-")) { //$NON-NLS-1$
|
||||
size = 5;
|
||||
}
|
||||
|
||||
if(alpha.length() > size) {
|
||||
alpha = alpha.substring(0, size);
|
||||
}
|
||||
|
||||
if(alpha.length() > 1) {
|
||||
if(alpha.endsWith("0")) { //$NON-NLS-1$
|
||||
alpha = alpha.substring(0, size - 1);
|
||||
}
|
||||
}
|
||||
return "(" + labelName + ", " + alpha + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
setInputDistancesTable();
|
||||
}
|
||||
|
||||
public void setInputDistancesTable() {
|
||||
List<Object[]> distances = new LinkedList<Object[]>();
|
||||
List<TwoTupleValuation> idealDistances = model.getIdealDistances();
|
||||
List<TwoTupleValuation> noIdealDistances = model.getNoIdealDistances();
|
||||
for(int i = 0; i < model.getIdealDistances().size(); ++i) {
|
||||
Object[] distanceData = new Object[3];
|
||||
distanceData[0] = problemElementService.getAll(Alternative.Type)[i];
|
||||
distanceData[1] = idealDistances.get(i);
|
||||
distanceData[2] = noIdealDistances.get(i);
|
||||
distances.add(distanceData);
|
||||
}
|
||||
|
||||
Collections.sort(distances, new DataComparator());
|
||||
|
||||
positiveNegativeProvider.setInput(distances);
|
||||
tableViewerPositiveNegative.setInput(positiveNegativeProvider.getInput());
|
||||
for(TableColumn tc: tableViewerPositiveNegative.getTable().getColumns()) {
|
||||
tc.pack();
|
||||
}
|
||||
}
|
||||
|
||||
private void createClosenessCoefficientsTable() {
|
||||
GridLayout distanceIdealSolutionLayout = new GridLayout(1, false);
|
||||
distanceIdealSolutionLayout.marginWidth = 10;
|
||||
distanceIdealSolutionLayout.marginHeight = 10;
|
||||
|
||||
Composite distanceIdealSolutionPanel = new Composite(informationPanel, SWT.NONE);
|
||||
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
|
||||
distanceIdealSolutionPanel.setLayoutData(gridData);
|
||||
distanceIdealSolutionPanel.setLayout(distanceIdealSolutionLayout);
|
||||
|
||||
Label colLectiveValuationsLabel = new Label(distanceIdealSolutionPanel, SWT.NONE);
|
||||
colLectiveValuationsLabel.setText(messages.CalculateDistances_Ideal_solution_distance);
|
||||
UiService.setFont(colLectiveValuationsLabel, UiService.FONT_TEXT_BOLD);
|
||||
gridData = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
|
||||
colLectiveValuationsLabel.setLayoutData(gridData);
|
||||
|
||||
tableViewerClosenessCoefficients = new TableViewer(distanceIdealSolutionPanel, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
|
||||
|
||||
tableViewerClosenessCoefficients.getTable().setLayoutData(gridData);
|
||||
tableViewerClosenessCoefficients.getTable().setHeaderVisible(true);
|
||||
|
||||
closenessCoefficientsProvider = ContextInjectionFactory.make(ClosenessCoefficientsTableViewerContentProvider.class, context);
|
||||
tableViewerClosenessCoefficients.setContentProvider(closenessCoefficientsProvider);
|
||||
|
||||
TableViewerColumn alternativeColumn = new TableViewerColumn(tableViewerClosenessCoefficients, SWT.NONE);
|
||||
alternativeColumn.getColumn().setText(messages.CalculateDistances_Alternative);
|
||||
alternativeColumn.getColumn().setResizable(true);
|
||||
alternativeColumn.getColumn().setMoveable(true);
|
||||
alternativeColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
return ((Alternative) data[0]).getName();
|
||||
}
|
||||
});
|
||||
|
||||
TableViewerColumn closenessCoefficient = new TableViewerColumn(tableViewerClosenessCoefficients, SWT.NONE);
|
||||
closenessCoefficient.getColumn().setText(messages.CalculateDistances_Closeness_coefficient);
|
||||
closenessCoefficient.getColumn().setResizable(false);
|
||||
closenessCoefficient.getColumn().setMoveable(false);
|
||||
closenessCoefficient.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
TwoTupleValuation distance = (TwoTupleValuation) data[1];
|
||||
|
||||
String labelName = distance.getLabel().getName();
|
||||
String alpha = Double.toString(distance.getAlpha());
|
||||
|
||||
if(alpha.equals("-0.0") || alpha.equals("0.0")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
alpha = "0"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
int size = 4;
|
||||
if(alpha.startsWith("-")) { //$NON-NLS-1$
|
||||
size = 5;
|
||||
}
|
||||
|
||||
if(alpha.length() > size) {
|
||||
alpha = alpha.substring(0, size);
|
||||
}
|
||||
|
||||
if(alpha.length() > 1) {
|
||||
if(alpha.endsWith("0")) { //$NON-NLS-1$
|
||||
alpha = alpha.substring(0, size - 1);
|
||||
}
|
||||
}
|
||||
return "(" + labelName + ", " + alpha + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
});
|
||||
|
||||
TableViewerColumn ranking = new TableViewerColumn(tableViewerClosenessCoefficients, SWT.NONE);
|
||||
ranking.getColumn().setText(messages.CalculateDistances_Ranking);
|
||||
ranking.getColumn().setResizable(false);
|
||||
ranking.getColumn().setMoveable(false);
|
||||
ranking.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
return (Integer.toString((int) data[2]));
|
||||
}
|
||||
});
|
||||
|
||||
setInputCoefficientsTable();
|
||||
|
||||
alternativeColumn.getColumn().pack();
|
||||
closenessCoefficient.getColumn().pack();
|
||||
ranking.getColumn().pack();
|
||||
}
|
||||
|
||||
private void setInputCoefficientsTable() {
|
||||
closenessCoefficientsProvider.setInput(model.getClosenessCoeficient());
|
||||
tableViewerClosenessCoefficients.setInput(closenessCoefficientsProvider.getInput());
|
||||
tableViewerClosenessCoefficients.refresh(true);
|
||||
for(TableColumn tc: tableViewerClosenessCoefficients.getTable().getColumns()) {
|
||||
tc.pack();
|
||||
}
|
||||
}
|
||||
|
||||
private void createChart() {
|
||||
Composite chartViewParent = new Composite(distanceEditorPanel, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(1, false);
|
||||
chartViewParent.setLayout(layout);
|
||||
chartViewParent.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
chartView = new Composite(chartViewParent, SWT.NONE);
|
||||
GridData gd = UiService.setGridData(chartView, 9, 9, true, true);
|
||||
gd.heightHint = 200;
|
||||
|
||||
setChart(model.getDistanceDomain());
|
||||
}
|
||||
|
||||
private void setChart(FuzzySet distanceDomain) {
|
||||
removeChart();
|
||||
|
||||
chart = uiDomainService.createChart(model.getDistanceDomain().getType());
|
||||
chart.initialize(distanceDomain, chartView, chartView.getSize().x, chartView.getSize().y, SWT.BORDER);
|
||||
|
||||
if (controlListener == null) {
|
||||
controlListener = new ControlAdapter() {
|
||||
@Override
|
||||
public void controlResized(ControlEvent e) {
|
||||
setChart(distanceDomain);
|
||||
}
|
||||
};
|
||||
chartView.addControlListener(controlListener);
|
||||
}
|
||||
|
||||
displayAlternatives();
|
||||
|
||||
}
|
||||
|
||||
private void removeChart() {
|
||||
if (chart != null) {
|
||||
chart.getChartComposite().dispose();
|
||||
chartView.layout();
|
||||
}
|
||||
}
|
||||
|
||||
private void createRetranslationCombo() {
|
||||
retranslationCombo = new Combo(distanceEditorPanel, SWT.NONE);
|
||||
retranslationCombo.setLayoutData(new GridData(SWT.RIGHT, SWT.RIGHT, false, false, 1, 1));
|
||||
retranslationCombo.setItems(model.getDistanceDomainsIds());
|
||||
retranslationCombo.add(model.getDefaultDistanceDomain().getName(), 0);
|
||||
retranslationCombo.select(0);
|
||||
|
||||
retranslationCombo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
String id = retranslationCombo.getText();
|
||||
FuzzySet selectedDomain = model.getDistanceDomain(id);
|
||||
|
||||
if(selectedDomain == null)
|
||||
selectedDomain = model.getDefaultDistanceDomain();
|
||||
|
||||
model.setDistanceDomain(selectedDomain);
|
||||
model.retranslateResults();
|
||||
setChart(selectedDomain);
|
||||
setInputCoefficientsTable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void displayAlternatives() {
|
||||
Map<Alternative, Valuation> closenessCoefficients = model.getClosenessCoeficient();
|
||||
|
||||
String[] alternatives = new String[closenessCoefficients.size()];
|
||||
int[] pos = new int[alternatives.length];
|
||||
double[] alpha = new double[alternatives.length];
|
||||
|
||||
int alt = 0;
|
||||
for(Alternative a: closenessCoefficients.keySet()) {
|
||||
alternatives[alt] = "a" + (Arrays.asList(problemElementService.getAll(Alternative.Type)).indexOf(a) + 1);
|
||||
pos[alt] = model.getDistanceDomain().getLabelSet().getPos(((TwoTupleValuation) closenessCoefficients.get(a)).getLabel());
|
||||
alpha[alt] = ((TwoTupleValuation) closenessCoefficients.get(a)).getAlpha();
|
||||
alt++;
|
||||
}
|
||||
chart.displayAlternatives(alternatives, pos, alpha);
|
||||
}
|
||||
|
||||
private void setSensitivityAnalysisData() {
|
||||
setDecisionMatrix();
|
||||
setWeights();
|
||||
setFinalPreferences();
|
||||
}
|
||||
|
||||
private void setDecisionMatrix() {
|
||||
Valuation[][] dm = model.getDecisionMatrix();
|
||||
Double[][] dmNumbers = new Double[dm.length][dm[0].length];
|
||||
for(int i = 0; i < dm.length; ++i) {
|
||||
for(int j = 0; j < dm[i].length; ++j) {
|
||||
dmNumbers[i][j] = (double) (Math.round(((TwoTupleValuation) dm[i][j]).calculateInverseDelta() * 100d) / 100d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setWeights() {
|
||||
TwoTupleValuation[] weights = model.getCriteriaWeights();
|
||||
Double[] weightsNumber = new Double[weights.length];
|
||||
int wcont = 0;
|
||||
double acum = 0;
|
||||
for(TwoTupleValuation weight: weights) {
|
||||
weightsNumber[wcont] = weight.calculateInverseDelta();
|
||||
acum += weightsNumber[wcont];
|
||||
wcont++;
|
||||
}
|
||||
|
||||
for(int i = 0; i < weightsNumber.length; ++i) {
|
||||
weightsNumber[i] /= acum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setFinalPreferences() {
|
||||
Map<Alternative, Valuation> coefficients = model.getClosenessCoeficient();
|
||||
Double[] preferences = new Double[coefficients.size()];
|
||||
int cont = 0;
|
||||
for(Alternative a: coefficients.keySet()) {
|
||||
preferences[cont] = ((TwoTupleValuation) coefficients.get(a)).calculateInverseDelta();
|
||||
cont++;
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshChart() {
|
||||
disposeControlsChartComposite();
|
||||
|
||||
chart = uiDomainService.createChart(model.getDistanceDomain().getType());
|
||||
chart.initialize(model.getDistanceDomain(), chartView, chartView.getSize().x, chartView.getSize().y, SWT.BORDER);
|
||||
|
||||
displayAlternatives();
|
||||
}
|
||||
|
||||
private void disposeControlsChartComposite() {
|
||||
for(Control c: chartView.getChildren()) {
|
||||
c.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
+330
@@ -0,0 +1,330 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.jface.viewers.ColumnLabelProvider;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.viewers.TableViewerColumn;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
|
||||
import flintstones.entity.method.phase.ui.PhaseMethodUI;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.method.decision.common.phase.selection.CalculateSolutionsSelectionModel;
|
||||
import flintstones.method.decision.common.phase.selection.ui.messages.Messages;
|
||||
import flintstones.method.decision.common.phase.selection.ui.provider.IdealSolutionTableViewerContentProvider;
|
||||
import flintstones.method.decision.common.phase.selection.ui.provider.NoIdealSolutionTableViewerContentProvider;
|
||||
import flintstones.method.decision.common.phase.selection.ui.table.DecisionMatrixTable;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
import flintstones.valuation.twoTuple.TwoTupleValuation;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class CalculateSolutionsSelectionUI extends PhaseMethodUI {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
Messages messages;
|
||||
|
||||
CalculateSolutionsSelectionModel model;
|
||||
|
||||
private Composite parent;
|
||||
private Composite solutionsComposite;
|
||||
|
||||
private Combo expertsCombo;
|
||||
|
||||
private TableViewer tableViewerIdealSolution;
|
||||
private TableViewer tableViewerNoIdealSolution;
|
||||
private DecisionMatrixTable decisionMatrixTable;
|
||||
|
||||
private IdealSolutionTableViewerContentProvider idealSolutionProvider;
|
||||
private NoIdealSolutionTableViewerContentProvider noIdealSolutionProvider;
|
||||
|
||||
private Valuation[][] decisionMatrix;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
model = (CalculateSolutionsSelectionModel) this.getModel();
|
||||
Composite parent = this.getBaseComposite();
|
||||
createPartControl(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
model.execute(decisionMatrix);
|
||||
setInputTableCollective();
|
||||
setInputIdealSolutionTable();
|
||||
setInputNoIdealSolution();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForwardEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSkippable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void createPartControl(Composite parent) {
|
||||
decisionMatrix = model.getCollectiveDecisionMatrix();
|
||||
|
||||
model.execute(decisionMatrix);
|
||||
|
||||
this.parent = parent;
|
||||
|
||||
createContent();
|
||||
}
|
||||
|
||||
private void createContent() {
|
||||
UiService.setGridLayout(parent, 1, false);
|
||||
UiService.setGridData(parent, 9, 9, true, true);
|
||||
|
||||
createInfoByExpertCombo();
|
||||
createCollectiveValuationsTable();
|
||||
|
||||
solutionsComposite = new Composite(parent, SWT.NONE);
|
||||
UiService.setGridLayout(solutionsComposite, 2, true);
|
||||
UiService.setGridData(solutionsComposite, 9, 9, true, true);
|
||||
|
||||
createIdealSolutionTable();
|
||||
createNoIdealSolutionTable();
|
||||
}
|
||||
|
||||
private void createInfoByExpertCombo() {
|
||||
Composite comboComposite = new Composite(parent, SWT.NONE);
|
||||
UiService.setGridData(comboComposite, 9, 9, true, false);
|
||||
UiService.setGridLayout(comboComposite, 2, false);
|
||||
|
||||
Label selectExpertLabel = new Label(comboComposite, SWT.NONE);
|
||||
selectExpertLabel.setText("Select expert:");
|
||||
UiService.setFont(selectExpertLabel, UiService.FONT_TEXT_BOLD);
|
||||
|
||||
expertsCombo = new Combo(comboComposite, SWT.NONE);
|
||||
expertsCombo.setItems(model.getExpertsName());
|
||||
expertsCombo.add(messages.Collective, expertsCombo.getItemCount());
|
||||
expertsCombo.select(expertsCombo.getItemCount() - 1);
|
||||
expertsCombo.addSelectionListener(changeInfoSelectionListener());
|
||||
}
|
||||
|
||||
private SelectionListener changeInfoSelectionListener() {
|
||||
return new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
String selection = expertsCombo.getText();
|
||||
if(model.isExpert(selection))
|
||||
decisionMatrix = model.getExpertDecisionMatrix(selection);
|
||||
else
|
||||
decisionMatrix = model.getCollectiveDecisionMatrix();
|
||||
|
||||
refresh();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void createCollectiveValuationsTable() {
|
||||
Composite decisionMatrixComposite = new Composite(parent, SWT.NONE);
|
||||
UiService.setGridData(decisionMatrixComposite, 9, 9, true, true);
|
||||
GridLayout layout = UiService.setGridLayout(decisionMatrixComposite, 1, true);
|
||||
layout.horizontalSpacing = 15;
|
||||
layout.verticalSpacing = 15;
|
||||
|
||||
decisionMatrixTable = new DecisionMatrixTable(decisionMatrixComposite);
|
||||
ContextInjectionFactory.inject(decisionMatrixTable, context);
|
||||
UiService.setGridData(decisionMatrixTable, 9, 9, true, true);
|
||||
decisionMatrixTable.setModel(decisionMatrix);
|
||||
}
|
||||
|
||||
private void setInputTableCollective() {
|
||||
decisionMatrixTable.setModel(decisionMatrix);
|
||||
decisionMatrixTable.redraw();
|
||||
}
|
||||
|
||||
private void createIdealSolutionTable() {
|
||||
Composite idealSolutionComposite = new Composite(solutionsComposite, SWT.NONE);
|
||||
UiService.setGridLayout(idealSolutionComposite, 1, true);
|
||||
UiService.setGridData(idealSolutionComposite, 9, 9, true, true);
|
||||
|
||||
Label idealSolutionLabel = new Label(idealSolutionComposite, SWT.NONE);
|
||||
idealSolutionLabel.setText(messages.calculate_solutions_Ideal_solution);
|
||||
UiService.setFont(idealSolutionLabel, UiService.FONT_TEXT_BOLD);
|
||||
UiService.setGridData(idealSolutionLabel, 0, 0, true, false);
|
||||
|
||||
tableViewerIdealSolution = new TableViewer(idealSolutionComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
UiService.setGridData(tableViewerIdealSolution.getTable(), 9, 9, true, true);
|
||||
tableViewerIdealSolution.getTable().setHeaderVisible(true);
|
||||
|
||||
idealSolutionProvider = ContextInjectionFactory.make(IdealSolutionTableViewerContentProvider.class, context);
|
||||
tableViewerIdealSolution.setContentProvider(idealSolutionProvider);
|
||||
|
||||
createIdealSolutionTableColumns();
|
||||
setInputIdealSolutionTable();
|
||||
}
|
||||
|
||||
private void createIdealSolutionTableColumns() {
|
||||
TableViewerColumn criterionColumn = new TableViewerColumn(tableViewerIdealSolution, SWT.NONE);
|
||||
criterionColumn.getColumn().setText(messages.calculate_solutions_Criterion);
|
||||
criterionColumn.getColumn().pack();
|
||||
criterionColumn.getColumn().setResizable(false);
|
||||
criterionColumn.getColumn().setMoveable(false);
|
||||
criterionColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
return ((Criterion) data[0]).getName();
|
||||
}
|
||||
});
|
||||
|
||||
TableViewerColumn typeColumn = new TableViewerColumn(tableViewerIdealSolution, SWT.NONE);
|
||||
typeColumn.getColumn().setText(messages.calculate_solutions_Type);
|
||||
typeColumn.getColumn().pack();
|
||||
typeColumn.getColumn().setResizable(false);
|
||||
typeColumn.getColumn().setMoveable(false);
|
||||
typeColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
if (((Criterion) data[0]).isCost()) {
|
||||
return UiService.getIcon("cost.png").createImage(); //$NON-NLS-1$
|
||||
}
|
||||
return UiService.getIcon("benefit.png").createImage(); //$NON-NLS-1$
|
||||
}
|
||||
});
|
||||
|
||||
TableViewerColumn valuationColumn = new TableViewerColumn(tableViewerIdealSolution, SWT.NONE);
|
||||
valuationColumn.getColumn().setText(messages.calculate_solutions_Valuation);
|
||||
valuationColumn.getColumn().pack();
|
||||
valuationColumn.getColumn().setResizable(true);
|
||||
valuationColumn.getColumn().setMoveable(true);
|
||||
valuationColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
TwoTupleValuation valuation = (TwoTupleValuation) data[1];
|
||||
|
||||
String valuationString = valuation.prettyFormat();
|
||||
valuationString = valuationString.replace("(", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
valuationString = valuationString.replace(")", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String[] elements = valuationString.split(","); //$NON-NLS-1$
|
||||
|
||||
return "(" + elements[0] + ", " + elements[1] + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void setInputIdealSolutionTable() {
|
||||
idealSolutionProvider.setInput(model.getIdealSolution());
|
||||
tableViewerIdealSolution.setInput(idealSolutionProvider.getInput());
|
||||
|
||||
for (TableColumn tc : tableViewerIdealSolution.getTable().getColumns())
|
||||
tc.pack();
|
||||
}
|
||||
|
||||
private void createNoIdealSolutionTable() {
|
||||
Composite noIdealSolutionComposite = new Composite(solutionsComposite, SWT.NONE);
|
||||
UiService.setGridLayout(noIdealSolutionComposite, 1, true);
|
||||
UiService.setGridData(noIdealSolutionComposite, 9, 9, true, true);
|
||||
|
||||
Label noIdealSolutionLabel = new Label(noIdealSolutionComposite, SWT.NONE);
|
||||
noIdealSolutionLabel.setText(messages.calculate_solutions_No_ideal_solution);
|
||||
UiService.setFont(noIdealSolutionLabel, UiService.FONT_TEXT_BOLD);
|
||||
UiService.setGridData(noIdealSolutionLabel, 0, 0, true, false);
|
||||
|
||||
tableViewerNoIdealSolution = new TableViewer(noIdealSolutionComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
UiService.setGridData(tableViewerNoIdealSolution.getTable(), 9, 9, true, true);
|
||||
tableViewerNoIdealSolution.getTable().setHeaderVisible(true);
|
||||
|
||||
noIdealSolutionProvider = ContextInjectionFactory.make(NoIdealSolutionTableViewerContentProvider.class, context);
|
||||
tableViewerNoIdealSolution.setContentProvider(noIdealSolutionProvider);
|
||||
|
||||
createNoIdealSolutionTableColumns();
|
||||
setInputNoIdealSolution();
|
||||
}
|
||||
|
||||
private void createNoIdealSolutionTableColumns() {
|
||||
TableViewerColumn criterionColumn = new TableViewerColumn(tableViewerNoIdealSolution, SWT.NONE);
|
||||
criterionColumn.getColumn().setText(messages.calculate_solutions_Criterion);
|
||||
criterionColumn.getColumn().pack();
|
||||
criterionColumn.getColumn().setResizable(false);
|
||||
criterionColumn.getColumn().setMoveable(false);
|
||||
criterionColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
return ((Criterion) data[0]).getName();
|
||||
}
|
||||
});
|
||||
|
||||
TableViewerColumn typeColumn = new TableViewerColumn(tableViewerNoIdealSolution, SWT.NONE);
|
||||
typeColumn.getColumn().setText(messages.calculate_solutions_Type);
|
||||
typeColumn.getColumn().pack();
|
||||
typeColumn.getColumn().setResizable(false);
|
||||
typeColumn.getColumn().setMoveable(false);
|
||||
typeColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
if (((Criterion) data[0]).isCost()) {
|
||||
return UiService.getIcon("cost.png").createImage(); //$NON-NLS-1$
|
||||
}
|
||||
return UiService.getIcon("benefit.png").createImage(); //$NON-NLS-1$
|
||||
}
|
||||
});
|
||||
|
||||
TableViewerColumn valuationColumn = new TableViewerColumn(tableViewerNoIdealSolution, SWT.NONE);
|
||||
valuationColumn.getColumn().setText(messages.calculate_solutions_Valuation);
|
||||
valuationColumn.getColumn().pack();
|
||||
valuationColumn.getColumn().setResizable(true);
|
||||
valuationColumn.getColumn().setMoveable(true);
|
||||
valuationColumn.setLabelProvider(new ColumnLabelProvider() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Object[] data = (Object[]) element;
|
||||
TwoTupleValuation valuation = (TwoTupleValuation) data[1];
|
||||
|
||||
String valuationString = valuation.prettyFormat();
|
||||
valuationString = valuationString.replace("(", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
valuationString = valuationString.replace(")", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String[] elements = valuationString.split(","); //$NON-NLS-1$
|
||||
|
||||
return "(" + elements[0] + ", " + elements[1] + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void setInputNoIdealSolution() {
|
||||
noIdealSolutionProvider.setInput(model.getNoIdealSolution());
|
||||
tableViewerNoIdealSolution.setInput(noIdealSolutionProvider.getInput());
|
||||
|
||||
for (TableColumn tc : tableViewerNoIdealSolution.getTable().getColumns())
|
||||
tc.pack();
|
||||
}
|
||||
}
|
||||
+304
@@ -0,0 +1,304 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import flintstones.domain.fuzzyset.FuzzySet;
|
||||
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
|
||||
import flintstones.domain.fuzzyset.ui.chart.LinguisticDomainChart;
|
||||
import flintstones.entity.domain.ui.chart.DomainChart;
|
||||
import flintstones.entity.method.phase.ui.PhaseMethodUI;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.method.decision.common.phase.selection.CalculateWeightsSelectionModel;
|
||||
import flintstones.method.decision.common.phase.selection.ui.handler.PasteWeightsHandler;
|
||||
import flintstones.method.decision.common.phase.selection.ui.messages.Messages;
|
||||
import flintstones.method.decision.common.phase.selection.ui.table.ExpertsWeightTable;
|
||||
import flintstones.model.domain.ui.service.IDomainUIService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
public class CalculateWeightsUI extends PhaseMethodUI {
|
||||
|
||||
//private static final String[] FILTER_NAMES = { "Text files (*.txt)" }; //$NON-NLS-1$
|
||||
//private static final String[] FILTER_EXTS = { "*.txt" }; //$NON-NLS-1$
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
IDomainUIService uiDomainService;
|
||||
|
||||
private Composite parent;
|
||||
private Composite tableComposite;
|
||||
private Composite chartView;
|
||||
|
||||
private ControlAdapter controlListener;
|
||||
|
||||
private Combo weightsDomainCombo;
|
||||
|
||||
private ExpertsWeightTable expertsWeightTable;
|
||||
|
||||
private DomainChart chart;
|
||||
|
||||
private CalculateWeightsSelectionModel model;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
Messages messages;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
model = (CalculateWeightsSelectionModel) this.getModel();
|
||||
Composite parent = this.getBaseComposite();
|
||||
createPartControl(parent);
|
||||
model.exportData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
model.execute();
|
||||
expertsWeightTable.redraw();
|
||||
setChart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForwardEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSkippable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void createPartControl(Composite parent) {
|
||||
this.parent = parent;
|
||||
|
||||
GridLayout layout = UiService.setGridLayout(this.parent, 1, true);
|
||||
UiService.setGridData(this.parent, 9, 9, true, true);
|
||||
layout.horizontalSpacing = 15;
|
||||
layout.verticalSpacing = 15;
|
||||
|
||||
createContent();
|
||||
|
||||
model.execute();
|
||||
}
|
||||
|
||||
private void createContent() {
|
||||
createTable();
|
||||
createButtonsFile();
|
||||
createChart();
|
||||
}
|
||||
|
||||
private void createTable() {
|
||||
tableComposite = new Composite(parent, SWT.NONE);
|
||||
UiService.setGridLayout(tableComposite, 1, true);
|
||||
UiService.setGridData(tableComposite, 9, 9, true, true);
|
||||
|
||||
expertsWeightTable = new ExpertsWeightTable(tableComposite);
|
||||
ContextInjectionFactory.inject(expertsWeightTable, context);
|
||||
UiService.setGridData(expertsWeightTable, 9, 9, true, true);
|
||||
expertsWeightTable.setModel(model);
|
||||
}
|
||||
|
||||
private void createButtonsFile() {
|
||||
Composite buttonsComposite = new Composite(tableComposite, SWT.NONE);
|
||||
GridLayout layout = UiService.setGridLayout(buttonsComposite, 2, false);
|
||||
UiService.setGridData(buttonsComposite, 1, 1, true, false);
|
||||
layout.horizontalSpacing = 15;
|
||||
layout.verticalSpacing = 15;
|
||||
|
||||
/*Button exportWeights = new Button(buttonsComposite, SWT.NONE);
|
||||
exportWeights.setText(messages.Export_weights);
|
||||
UiService.setGridData(exportWeights, 1, 9, true, true);
|
||||
exportWeights.addSelectionListener(createExportWeightsSelectionAdapter());*/
|
||||
|
||||
weightsDomainCombo = new Combo(buttonsComposite, SWT.NONE);
|
||||
UiService.setGridData(weightsDomainCombo, 1, 9, true, true);
|
||||
weightsDomainCombo.setItems(model.getWeightsDomainsIds());
|
||||
weightsDomainCombo.add(model.getDefaultWeightsDomain().getName(), 0);
|
||||
weightsDomainCombo.addSelectionListener(createWeightDomainSelectionAdapter());
|
||||
weightsDomainCombo.select(0);
|
||||
|
||||
Button importWeights = new Button(buttonsComposite, SWT.NONE);
|
||||
importWeights.setText(messages.Import_weights);
|
||||
UiService.setGridData(importWeights, 1, 9, true, true);
|
||||
importWeights.addSelectionListener(createImportWeightsSelectionAdapter());
|
||||
}
|
||||
|
||||
private SelectionListener createImportWeightsSelectionAdapter() {
|
||||
return new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
PasteWeightsHandler handler = new PasteWeightsHandler();
|
||||
ContextInjectionFactory.inject(handler, context);
|
||||
|
||||
Map<Expert, LabelLinguisticDomain[]> expertsWeights = handler.execute(model.getCurrentWeightsDomain());
|
||||
if(expertsWeights != null) {
|
||||
model.setExperstWeights(expertsWeights);
|
||||
refresh();
|
||||
}
|
||||
|
||||
/*FileDialog dlg = new FileDialog(Display.getDefault().getActiveShell(), SWT.OPEN);
|
||||
dlg.setFilterNames(FILTER_NAMES);
|
||||
dlg.setFilterExtensions(FILTER_EXTS);
|
||||
String fileName = dlg.open();
|
||||
|
||||
if(fileName != null) {
|
||||
readFileContent(fileName);
|
||||
}*/
|
||||
}
|
||||
|
||||
/*private void readFileContent(String fileName) {
|
||||
Map<Expert, LabelLinguisticDomain[]> expertsWeights = new HashMap<>();
|
||||
|
||||
FileReader fr = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
fr = new FileReader(fileName);
|
||||
br = new BufferedReader(fr);
|
||||
|
||||
String sCurrentLine;
|
||||
while ((sCurrentLine = br.readLine()) != null) {
|
||||
String[] info = sCurrentLine.split(":");
|
||||
Expert e = (Expert) problemService.getByName(Expert.Type, info[0]);
|
||||
Criterion criterion = (Criterion) problemService.getByName(Criterion.Type, info[1]);
|
||||
LabelLinguisticDomain weight = model.getWeightsDomain().getLabelSet().getLabel(info[2]);
|
||||
|
||||
LabelLinguisticDomain[] weights;
|
||||
if(expertsWeights.get(e) == null) {
|
||||
weights = new LabelLinguisticDomain[(problemService.getSubElements(Criterion.Type).length)];
|
||||
expertsWeights.put(e, weights);
|
||||
} else
|
||||
weights = expertsWeights.get(e);
|
||||
|
||||
weights[Arrays.asList(problemService.getSubElements(Criterion.Type)).indexOf(criterion)] = weight;
|
||||
}
|
||||
|
||||
model.setExperstWeights(expertsWeights);
|
||||
refresh();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (br != null)
|
||||
br.close();
|
||||
|
||||
if (fr != null)
|
||||
fr.close();
|
||||
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
};
|
||||
}
|
||||
|
||||
/*private SelectionListener createExportWeightsSelectionAdapter() {
|
||||
return new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
FileDialog dlg = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE);
|
||||
dlg.setFilterNames(FILTER_NAMES);
|
||||
dlg.setFilterExtensions(FILTER_EXTS);
|
||||
String fileName = dlg.open();
|
||||
|
||||
if(fileName != null)
|
||||
generateFileContent(fileName);
|
||||
}
|
||||
|
||||
private void generateFileContent(String fileName) {
|
||||
StringBuilder content = new StringBuilder();
|
||||
for(ProblemElement e: problemService.getSubElements(Expert.Type)) {
|
||||
for(ProblemElement c: problemService.getSubElements(Criterion.Type)) {
|
||||
content.append(e.getName() + ":" + c.getName() + ":" + model.getExpertWeight((Expert) e,
|
||||
Arrays.asList(problemService.getSubElements(Criterion.Type)).indexOf(c)).getName());
|
||||
content.append(System.getProperty("line.separator"));
|
||||
}
|
||||
}
|
||||
|
||||
content.deleteCharAt(content.length() - 1);
|
||||
content.deleteCharAt(content.length() - 1);
|
||||
|
||||
PrintWriter writer;
|
||||
try {
|
||||
writer = new PrintWriter(fileName, "UTF-8");
|
||||
writer.println(content.toString());
|
||||
writer.close();
|
||||
} catch (FileNotFoundException | UnsupportedEncodingException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
}*/
|
||||
|
||||
private SelectionListener createWeightDomainSelectionAdapter() {
|
||||
return new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
String selectedDomainId = weightsDomainCombo.getText();
|
||||
|
||||
FuzzySet selectedDomain = model.getWeightsDomain(selectedDomainId);
|
||||
if(selectedDomain != null)
|
||||
model.setWeightsDomain(selectedDomain);
|
||||
else
|
||||
model.createWeightsLabels();
|
||||
|
||||
refresh();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void createChart() {
|
||||
chartView = new Composite(parent, SWT.NONE);
|
||||
GridData gd = UiService.setGridData(chartView, 9, 9, true, true);
|
||||
gd.heightHint = 200;
|
||||
setChart();
|
||||
}
|
||||
|
||||
private void setChart() {
|
||||
removeChart();
|
||||
|
||||
chart = new LinguisticDomainChart();
|
||||
chart.initialize(model.getCurrentWeightsDomain(), chartView, chartView.getSize().x, chartView.getSize().y, SWT.BORDER);
|
||||
|
||||
if (controlListener == null) {
|
||||
controlListener = new ControlAdapter() {
|
||||
@Override
|
||||
public void controlResized(ControlEvent e) {
|
||||
setChart();
|
||||
}
|
||||
};
|
||||
chartView.addControlListener(controlListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void removeChart() {
|
||||
if (chart != null) {
|
||||
chart.getChartComposite().dispose();
|
||||
chartView.layout();
|
||||
}
|
||||
}
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
|
||||
package flintstones.method.decision.common.phase.selection.ui.handler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.core.services.events.IEventBroker;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.nebula.widgets.opal.notifier.NotifierColorsFactory.NotifierTheme;
|
||||
import org.eclipse.nebula.widgets.opal.notifier.WNotifier;
|
||||
import org.eclipse.swt.dnd.Clipboard;
|
||||
import org.eclipse.swt.dnd.TextTransfer;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import flintstones.domain.fuzzyset.FuzzySet;
|
||||
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.helper.MatrixHelper;
|
||||
import flintstones.helper.data.HashMatrix;
|
||||
import flintstones.method.decision.common.phase.selection.ui.messages.Messages;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
|
||||
public class PasteWeightsHandler {
|
||||
|
||||
Map<Expert, LabelLinguisticDomain[]> criteriaWeightsByExperts = new HashMap<Expert, LabelLinguisticDomain[]>();
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Inject
|
||||
IEventBroker broker;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
Messages messages;
|
||||
|
||||
@Execute
|
||||
public Map<Expert, LabelLinguisticDomain[]> execute(FuzzySet domain) {
|
||||
|
||||
Clipboard clipboard = new Clipboard(Display.getCurrent());
|
||||
String plainText = (String) clipboard.getContents(TextTransfer.getInstance());
|
||||
|
||||
HashMatrix<String, String, String> data = MatrixHelper.toHashMatrix(plainText, true);
|
||||
|
||||
ProblemElement[] hHeaders = problemService.getSubElements(Expert.Type);
|
||||
ProblemElement[] vHeaders = problemService.getSubElements(Criterion.Type);
|
||||
|
||||
String crit, exp;
|
||||
LabelLinguisticDomain weight;
|
||||
LabelLinguisticDomain[] weights;
|
||||
|
||||
boolean error = false;
|
||||
|
||||
for (ProblemElement item1 : hHeaders) {
|
||||
|
||||
exp = item1.getName();
|
||||
|
||||
weights = new LabelLinguisticDomain[vHeaders.length];
|
||||
|
||||
for (ProblemElement item2 : vHeaders) {
|
||||
|
||||
crit = item2.getName();
|
||||
|
||||
try {
|
||||
int pos = Integer.parseInt(data.get(exp, crit));
|
||||
weight = domain.getLabelSet().getLabel(pos);
|
||||
} catch(NumberFormatException ex) {
|
||||
weight = domain.getLabelSet().getLabel(data.get(exp, crit));
|
||||
}
|
||||
|
||||
if(weight == null) {
|
||||
new WNotifier("Error", messages.Incorrect_domain) //$NON-NLS-1$
|
||||
.withCloseOnClick(true)
|
||||
.withTimeout(5)
|
||||
.send();
|
||||
|
||||
error = true;
|
||||
} else
|
||||
weights[Arrays.asList(vHeaders).indexOf(item2)] = weight;
|
||||
|
||||
|
||||
if(error)
|
||||
break;
|
||||
}
|
||||
|
||||
criteriaWeightsByExperts.put((Expert) item1, weights);
|
||||
|
||||
if(error)
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(!error) {
|
||||
new WNotifier(messages.Successfully_imported, messages.Weights_successfully_added,
|
||||
NotifierTheme.BLUE_THEME)
|
||||
.send();
|
||||
|
||||
return criteriaWeightsByExperts;
|
||||
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.method.decision.common.phase.selection.ui.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
|
||||
public String selection_Calculate_solutions;
|
||||
public String calculate_solutions_Alternative;
|
||||
public String calculate_solutions_Collective_valuation;
|
||||
public String calculate_solutions_Collective_valuations;
|
||||
public String calculate_solutions_Criterion;
|
||||
public String calculate_solutions_Expert;
|
||||
public String calculate_solutions_Ideal_solution;
|
||||
public String calculate_solutions_No_ideal_solution;
|
||||
public String calculate_solutions_Type;
|
||||
public String calculate_solutions_Valuation;
|
||||
public String CalculateDistances_Alternative;
|
||||
public String CalculateDistances_Calculate_distances;
|
||||
public String CalculateDistances_Closeness_coefficient;
|
||||
public String CalculateDistances_Criterion;
|
||||
public String CalculateDistances_Ideal_solution;
|
||||
public String CalculateDistances_Ideal_solution_distance;
|
||||
public String CalculateDistances_Negative_distance;
|
||||
public String CalculateDistances_Positive_distance;
|
||||
public String CalculateDistances_Ranking;
|
||||
public String selection_Calculate_weights;
|
||||
public String calculate_weights_Weight;
|
||||
public String Domain_entity;
|
||||
public String Collective;
|
||||
public String Export_weights;
|
||||
public String Import_weights;
|
||||
public String Fix_error;
|
||||
public String Weights_successfully_added;
|
||||
public String Successfully_imported;
|
||||
public String Incorrect_domain;
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
selection_Calculate_solutions=Calculate solutions
|
||||
calculate_solutions_Alternative=Alternative
|
||||
calculate_solutions_Collective_valuation=Collective valuation
|
||||
calculate_solutions_Collective_valuations=Collective valuations
|
||||
calculate_solutions_Criterion=Criterion
|
||||
calculate_solutions_Expert=Expert
|
||||
calculate_solutions_Ideal_solution=Ideal solution
|
||||
calculate_solutions_No_ideal_solution=No ideal solution
|
||||
calculate_solutions_Type=Type
|
||||
calculate_solutions_Valuation=Valuation
|
||||
CalculateDistances_Alternative=Alternative
|
||||
CalculateDistances_Calculate_distances=Calculate distances
|
||||
CalculateDistances_Closeness_coefficient=Closeness coefficient
|
||||
CalculateDistances_Criterion=Criterion
|
||||
CalculateDistances_Ideal_solution=Ideal and no ideal distances
|
||||
CalculateDistances_Ideal_solution_distance=Closeness coefficients
|
||||
CalculateDistances_Negative_distance=No ideal distance
|
||||
CalculateDistances_Positive_distance=Ideal distance
|
||||
CalculateDistances_Ranking=Ranking
|
||||
Collective=Collective*
|
||||
selection_Calculate_weights=Select weights
|
||||
calculate_weights_Weight=Weight
|
||||
Export_weights = Export weights
|
||||
Import_weights = Import weights
|
||||
Fix_error=\n Fix the error and remove the data to try again
|
||||
Weights_successfully_added=Weights successfully added
|
||||
Successfully_imported=Successfully imported
|
||||
Incorrect_domain=Incorrect domain
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
selection_Calculate_solutions=Calcular soluciones
|
||||
calculate_solutions_Alternative=Alternative
|
||||
calculate_solutions_Collective_valuation=Valoración collectiva
|
||||
calculate_solutions_Collective_valuations=Valoraciones colectivas
|
||||
calculate_solutions_Criterion=Criterio
|
||||
calculate_solutions_Expert=Experto
|
||||
calculate_solutions_Ideal_solution=Solución ideal
|
||||
calculate_solutions_No_ideal_solution=Solución anti ideal
|
||||
calculate_solutions_Type=Tipo
|
||||
calculate_solutions_Valuation=Valoración
|
||||
CalculateDistances_Alternative=Alternativa
|
||||
CalculateDistances_Calculate_distances=Calcular distancias
|
||||
CalculateDistances_Closeness_coefficient=Coeficiente de cercania
|
||||
CalculateDistances_Criterion=Criterio
|
||||
CalculateDistances_Ideal_solution=Distancia ideal y anti ideal
|
||||
CalculateDistances_Ideal_solution_distance=Coeficiente de cercanÃa
|
||||
CalculateDistances_Negative_distance=Distancia anti ideal
|
||||
CalculateDistances_Positive_distance=Distancia ideal
|
||||
CalculateDistances_Ranking=Ranking
|
||||
Collective = Colectiva*
|
||||
selection_Calculate_weights= Seleccionar pesos
|
||||
calculate_weights_Wight = Importancia
|
||||
Export_weights = Exportar pesos
|
||||
Import_weights = Importar pesos
|
||||
Fix_error=\n Corrige el error y elimina los datos para volver a intenarlo
|
||||
Weights_successfully_added=Se han añadido los pesos correctamente
|
||||
Successfully_imported=Importado con éxito
|
||||
Incorrect_domain=Dominio incorrecto
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui.provider;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
|
||||
//CK
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ClosenessCoefficientsTableViewerContentProvider implements IStructuredContentProvider {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
private List<Object[]> _closenessCoefficients;
|
||||
|
||||
public ClosenessCoefficientsTableViewerContentProvider() {
|
||||
_closenessCoefficients = new LinkedList<Object[]>();
|
||||
}
|
||||
|
||||
public void setInput(Map<Alternative, Valuation> closenessCoefficients) {
|
||||
_closenessCoefficients.clear();
|
||||
Object[] data;
|
||||
|
||||
int ranking = 1;
|
||||
for(Alternative a: closenessCoefficients.keySet()) {
|
||||
data = new Object[3];
|
||||
data[0] = a;
|
||||
data[1] = closenessCoefficients.get(a);
|
||||
data[2] = ranking;
|
||||
|
||||
ranking++;
|
||||
|
||||
_closenessCoefficients.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object[]> getInput() {
|
||||
return _closenessCoefficients;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
_closenessCoefficients.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ((List<Object[]>) inputElement).toArray();
|
||||
}
|
||||
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui.provider;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import de.kupzog.ktable.KTable;
|
||||
import de.kupzog.ktable.KTableCellEditor;
|
||||
import de.kupzog.ktable.KTableCellRenderer;
|
||||
import de.kupzog.ktable.KTableNoScrollModel;
|
||||
import de.kupzog.ktable.SWTX;
|
||||
import de.kupzog.ktable.renderers.DefaultCellRenderer;
|
||||
import de.kupzog.ktable.renderers.FixedCellRenderer;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.valuation.twoTuple.TwoTupleValuation;
|
||||
|
||||
//CK
|
||||
@SuppressWarnings("javadoc")
|
||||
public class DecisionMatrixContentProvider extends KTableNoScrollModel {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
private KTable _table;
|
||||
|
||||
private Valuation[][] decisionMatrix;
|
||||
|
||||
private final FixedCellRenderer _fixedRenderer = new FixedCellRenderer(DefaultCellRenderer.STYLE_FLAT | SWT.BOLD);
|
||||
private final FixedCellRenderer _fixedRendererInTable = new FixedCellRenderer(DefaultCellRenderer.STYLE_FLAT | DefaultCellRenderer.INDICATION_FOCUS);
|
||||
private final FixedCellRenderer _editableRenderer = new FixedCellRenderer(DefaultCellRenderer.STYLE_FLAT | DefaultCellRenderer.INDICATION_FOCUS);
|
||||
|
||||
|
||||
public DecisionMatrixContentProvider(KTable table) {
|
||||
super(table);
|
||||
_table = table;
|
||||
}
|
||||
|
||||
public void initDecisionMatrixContentProvider(Valuation[][] decisionMatrix) {
|
||||
this.decisionMatrix = decisionMatrix;
|
||||
initialize();
|
||||
setDesign();
|
||||
}
|
||||
|
||||
private void setDesign() {
|
||||
_fixedRenderer.setAlignment(SWTX.ALIGN_HORIZONTAL_CENTER | SWTX.ALIGN_VERTICAL_CENTER);
|
||||
_fixedRendererInTable.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
|
||||
|
||||
_editableRenderer.setAlignment(SWTX.ALIGN_HORIZONTAL_CENTER | SWTX.ALIGN_VERTICAL_CENTER);
|
||||
_editableRenderer.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedHeaderColumnCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedHeaderRowCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedSelectableColumnCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedSelectableRowCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowHeightMinimum() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isColumnResizable(int arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRowResizable(int arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KTableCellEditor doGetCellEditor(int arg0, int arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KTableCellRenderer doGetCellRenderer(int col, int row) {
|
||||
if((col < getFixedColumnCount()) || (row < getFixedRowCount())) {
|
||||
return _fixedRenderer;
|
||||
} else {
|
||||
return _editableRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doGetColumnCount() {
|
||||
return problemService.getAll(Alternative.Type).length + getFixedColumnCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object doGetContentAt(int col, int row) {
|
||||
if ((col == 0) && (row == 0)) {
|
||||
return "Decision matrix"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
Object content;
|
||||
|
||||
try {
|
||||
if (col == 0) {
|
||||
content = criterionAbbreviation(row);
|
||||
} else if (row == 0) {
|
||||
content = alternativeAbbreviation(col);
|
||||
} else {
|
||||
content = ((TwoTupleValuation) decisionMatrix[row - 1][ col - 1]).prettyFormat();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
content = ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
private Object criterionAbbreviation(int pos) {
|
||||
return problemService.getSubElements(Criterion.Type)[pos-1].getName();
|
||||
}
|
||||
|
||||
private Object alternativeAbbreviation(int pos) {
|
||||
return problemService.getAll(Alternative.Type)[pos-1].getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doGetRowCount() {
|
||||
return problemService.getSubElements(Criterion.Type).length + getFixedRowCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSetContentAt(int col, int row, Object value) {
|
||||
_table.redraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInitialColumnWidth(int arg0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInitialRowHeight(int arg0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFixedCell(int col, int row) {
|
||||
if (col == 0) {
|
||||
return true;
|
||||
} else if (row == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeaderCell(int col, int row) {
|
||||
return isFixedCell(col, row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doGetTooltipAt(int col, int row) {
|
||||
if ((col == 0) && (row == 0)) {
|
||||
return ""; //$NON-NLS-1$
|
||||
} else if (col < getFixedColumnCount()) {
|
||||
return problemService.getSubElements(Criterion.Type)[row-1].getName();
|
||||
} else if (row < getFixedRowCount()) {
|
||||
return problemService.getAll(Alternative.Type)[col-1].getName();
|
||||
} else {
|
||||
return ((Criterion) problemService.getSubElements(Criterion.Type)[row-1]).getName() + '/' + problemService.getAll(Alternative.Type)[col-1].getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
+224
@@ -0,0 +1,224 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui.provider;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import de.kupzog.ktable.KTable;
|
||||
import de.kupzog.ktable.KTableCellEditor;
|
||||
import de.kupzog.ktable.KTableCellRenderer;
|
||||
import de.kupzog.ktable.KTableNoScrollModel;
|
||||
import de.kupzog.ktable.SWTX;
|
||||
import de.kupzog.ktable.editors.KTableCellEditorCombo;
|
||||
import de.kupzog.ktable.renderers.DefaultCellRenderer;
|
||||
import de.kupzog.ktable.renderers.FixedCellRenderer;
|
||||
import flintstones.domain.fuzzyset.FuzzySet;
|
||||
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElementHelper;
|
||||
import flintstones.method.decision.common.phase.selection.CalculateWeightsSelectionModel;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
|
||||
//CK
|
||||
public class ExpertsWeightContentProvider extends KTableNoScrollModel {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
private KTable _table;
|
||||
|
||||
private CalculateWeightsSelectionModel model;
|
||||
|
||||
private final FixedCellRenderer _fixedRenderer = new FixedCellRenderer(DefaultCellRenderer.STYLE_FLAT | SWT.BOLD);
|
||||
private final FixedCellRenderer _fixedRendererInTable = new FixedCellRenderer(DefaultCellRenderer.STYLE_FLAT | DefaultCellRenderer.INDICATION_FOCUS);
|
||||
private final FixedCellRenderer _editableRenderer = new FixedCellRenderer(DefaultCellRenderer.STYLE_FLAT | DefaultCellRenderer.INDICATION_FOCUS);
|
||||
|
||||
private class MyOwnKTableCellEditorCombo extends KTableCellEditorCombo {
|
||||
@Override
|
||||
public int getActivationSignals() {
|
||||
return SINGLECLICK;
|
||||
}
|
||||
}
|
||||
|
||||
private MyOwnKTableCellEditorCombo kTableCombo = new MyOwnKTableCellEditorCombo();
|
||||
|
||||
public ExpertsWeightContentProvider(KTable table) {
|
||||
super(table);
|
||||
|
||||
}
|
||||
|
||||
public void init(KTable table, CalculateWeightsSelectionModel selectionPhase) {
|
||||
|
||||
_table = table;
|
||||
model = selectionPhase;
|
||||
|
||||
initialize();
|
||||
setDesign();
|
||||
}
|
||||
|
||||
private void setDesign() {
|
||||
_fixedRenderer.setAlignment(SWTX.ALIGN_HORIZONTAL_CENTER | SWTX.ALIGN_VERTICAL_CENTER);
|
||||
_fixedRendererInTable.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
|
||||
|
||||
_editableRenderer.setAlignment(SWTX.ALIGN_HORIZONTAL_CENTER | SWTX.ALIGN_VERTICAL_CENTER);
|
||||
_editableRenderer.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedHeaderColumnCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedHeaderRowCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedSelectableColumnCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedSelectableRowCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowHeightMinimum() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isColumnResizable(int arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRowResizable(int arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KTableCellEditor doGetCellEditor(int col, int row) {
|
||||
if (col != 0 && row != 0) {
|
||||
kTableCombo = new MyOwnKTableCellEditorCombo();
|
||||
FuzzySet weightsDomain = model.getCurrentWeightsDomain();
|
||||
|
||||
String[] valuesString = new String[weightsDomain.getLabelSet().getCardinality()];
|
||||
for(int i = 0; i < valuesString.length; ++i)
|
||||
valuesString[i] = weightsDomain.getLabelSet().getLabel(i).getName();
|
||||
|
||||
kTableCombo.setItems(valuesString);
|
||||
|
||||
return kTableCombo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KTableCellRenderer doGetCellRenderer(int col, int row) {
|
||||
if((col < getFixedColumnCount()) || (row < getFixedRowCount())) {
|
||||
return _fixedRenderer;
|
||||
} else {
|
||||
return _editableRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doGetColumnCount() {
|
||||
return problemService.getSubElements(Criterion.Type).length + getFixedColumnCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object doGetContentAt(int col, int row) {
|
||||
if ((col == 0) && (row == 0)) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
Object content;
|
||||
|
||||
try {
|
||||
if (col == 0) {
|
||||
content = expertAbbreviation(row);
|
||||
} else if (row == 0) {
|
||||
content = criterionAbbreviation(col);
|
||||
} else {
|
||||
content = model.getExpertWeight((Expert) problemService.getSubElements(Expert.Type)[row-1], col - 1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
content = ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
private Object criterionAbbreviation(int pos) {
|
||||
return ProblemElementHelper.getAsUserOrdered(problemService.getSubElements(Criterion.Type))[pos - 1].getName();
|
||||
}
|
||||
|
||||
private Object expertAbbreviation(int pos) {
|
||||
return ProblemElementHelper.getAsUserOrdered(problemService.getSubElements(Expert.Type))[pos - 1].getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doGetRowCount() {
|
||||
return problemService.getSubElements(Expert.Type).length + getFixedRowCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSetContentAt(int col, int row, Object value) {
|
||||
LabelLinguisticDomain oldWeight = model.getExpertWeight((Expert) problemService.getSubElements(Expert.Type)[row - 1], col - 1);
|
||||
LabelLinguisticDomain newWeight = model.getCurrentWeightsDomain().getLabelSet().getLabel((String) value);
|
||||
|
||||
if(!oldWeight.equals(newWeight)) {
|
||||
model.setExpertWeight((Expert) problemService.getSubElements(Expert.Type)[row - 1], col - 1, newWeight);
|
||||
_table.redraw();
|
||||
model.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInitialColumnWidth(int arg0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInitialRowHeight(int arg0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFixedCell(int col, int row) {
|
||||
if (col == 0) {
|
||||
return true;
|
||||
} else if (row == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeaderCell(int col, int row) {
|
||||
return isFixedCell(col, row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doGetTooltipAt(int col, int row) {
|
||||
if ((col == 0) && (row == 0)) {
|
||||
return ""; //$NON-NLS-1$
|
||||
} else if (col < getFixedColumnCount()) {
|
||||
return problemService.getSubElements(Expert.Type)[row - 1].getName();
|
||||
} else if (row < getFixedRowCount()) {
|
||||
return problemService.getSubElements(Criterion.Type)[col - 1].getName();
|
||||
} else {
|
||||
return problemService.getSubElements(Expert.Type)[row - 1].getName() + '/' + problemService.getSubElements(Criterion.Type)[col - 1].getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui.provider;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
|
||||
//CK
|
||||
public class IdealSolutionTableViewerContentProvider implements IStructuredContentProvider {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
private List<Object[]> idealSolutionData;
|
||||
|
||||
@Override
|
||||
public void dispose() {}
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
|
||||
|
||||
public IdealSolutionTableViewerContentProvider() {
|
||||
idealSolutionData = new LinkedList<Object[]>();
|
||||
}
|
||||
|
||||
public void setInput(List<Valuation> noIdealSolution) {
|
||||
|
||||
idealSolutionData.clear();
|
||||
|
||||
Object[] data;
|
||||
for(int i = 0; i < noIdealSolution.size(); ++i) {
|
||||
data = new Object[2];
|
||||
data[0] = problemService.getSubElements(Criterion.Type)[i];
|
||||
data[1] = noIdealSolution.get(i);
|
||||
|
||||
idealSolutionData.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object[]> getInput() {
|
||||
return idealSolutionData;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ((List<Object[]>) inputElement).toArray(new Object[0]);
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui.provider;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
|
||||
//CK
|
||||
public class NoIdealSolutionTableViewerContentProvider implements IStructuredContentProvider {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
private List<Object[]> noIdealSolutionData;
|
||||
|
||||
@Override
|
||||
public void dispose() {}
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
|
||||
|
||||
public NoIdealSolutionTableViewerContentProvider() {
|
||||
noIdealSolutionData = new LinkedList<Object[]>();
|
||||
}
|
||||
|
||||
public void setInput(List<Valuation> noIdealSolution) {
|
||||
|
||||
noIdealSolutionData.clear();
|
||||
|
||||
Object[] data;
|
||||
for(int i = 0; i < noIdealSolution.size(); ++i) {
|
||||
data = new Object[2];
|
||||
data[0] = problemService.getSubElements(Criterion.Type)[i];
|
||||
data[1] = noIdealSolution.get(i);
|
||||
|
||||
noIdealSolutionData.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object[]> getInput() {
|
||||
return noIdealSolutionData;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ((List<Object[]>) inputElement).toArray(new Object[0]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui.provider;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
//CK
|
||||
@SuppressWarnings("javadoc")
|
||||
public class PositiveNegativeTableViewerContentProvider implements IStructuredContentProvider {
|
||||
|
||||
private List<Object[]> _positiveNegativeDistances;
|
||||
|
||||
public PositiveNegativeTableViewerContentProvider() {
|
||||
_positiveNegativeDistances = new LinkedList<>();
|
||||
}
|
||||
|
||||
public List<Object[]> getInput() {
|
||||
return _positiveNegativeDistances;
|
||||
}
|
||||
|
||||
public void setInput(List<Object[]> positiveNegativeDistances) {
|
||||
_positiveNegativeDistances = positiveNegativeDistances;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
_positiveNegativeDistances.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ((List<Object[]>) inputElement).toArray();
|
||||
}
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui.table;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import de.kupzog.ktable.KTable;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.method.decision.common.phase.selection.ui.provider.DecisionMatrixContentProvider;
|
||||
|
||||
public class DecisionMatrixTable extends KTable {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
private DecisionMatrixContentProvider _model;
|
||||
|
||||
public DecisionMatrixTable(Composite parent) {
|
||||
super(parent, SWT.NO_BACKGROUND | SWT.FLAT | SWT.V_SCROLL);
|
||||
setBackground(new Color(Display.getCurrent(), 255, 255, 255));
|
||||
_model = null;
|
||||
}
|
||||
|
||||
public void setModel(Valuation[][] decisionMatrix) {
|
||||
_model = new DecisionMatrixContentProvider(this);
|
||||
ContextInjectionFactory.inject(_model, context);
|
||||
_model.initDecisionMatrixContentProvider(decisionMatrix);
|
||||
setModel(_model);
|
||||
getParent().getParent()
|
||||
.layout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package flintstones.method.decision.common.phase.selection.ui.table;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import de.kupzog.ktable.KTable;
|
||||
import flintstones.method.decision.common.phase.selection.CalculateWeightsSelectionModel;
|
||||
import flintstones.method.decision.common.phase.selection.ui.provider.ExpertsWeightContentProvider;
|
||||
|
||||
public class ExpertsWeightTable extends KTable {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
private ExpertsWeightContentProvider _model;
|
||||
|
||||
public ExpertsWeightTable(Composite parent) {
|
||||
super(parent, SWT.NO_BACKGROUND | SWT.FLAT | SWT.V_SCROLL);
|
||||
setBackground(new Color(Display.getCurrent(), 255, 255, 255));
|
||||
_model = null;
|
||||
}
|
||||
|
||||
public void setModel(CalculateWeightsSelectionModel selectionPhase) {
|
||||
_model = new ExpertsWeightContentProvider(this);
|
||||
ContextInjectionFactory.inject(_model, context);
|
||||
_model.init(this, selectionPhase);
|
||||
|
||||
setModel(_model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user