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.electre.phase.gathering.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.electre.phase.gathering.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>1779484362664</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,24 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ui
|
||||
Bundle-SymbolicName: flintstones.method.electre.phase.gathering.ui;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.electre.phase.gathering.ui
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Export-Package: flintstones.method.electre.phase.gathering.viewer
|
||||
Require-Bundle: flintstones.model.ui.service,
|
||||
org.eclipse.e4.core.contexts,
|
||||
javax.inject,
|
||||
flintstones.helper.data,
|
||||
flintstones.model.problemelement.service,
|
||||
flintstones.helper.html,
|
||||
org.eclipse.swt,
|
||||
org.eclipse.jface,
|
||||
flintstones.entity.problemelement,
|
||||
org.eclipse.e4.core.di,
|
||||
flintstones.application.perspective.framework.ui,
|
||||
flintstones.entity.method.phase.ui,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.method.electre.phase.gathering,
|
||||
flintstones.model.method.phase.service,
|
||||
flintstones.method.common.phase.aggregation
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="flintstones.phasemethod.ui">
|
||||
<phasemethod_ui
|
||||
uid="flintstones.method.electre.phase.gathering.ui"
|
||||
implementation="flintstones.method.electre.phase.gathering.ui.PhaseElectreUI"
|
||||
phasemethod="flintstones.method.electre.phase.gathering">
|
||||
</phasemethod_ui>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package flintstones.method.electre.phase.gathering.provider;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.StyledString;
|
||||
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.model.method.phase.IPhaseMethodService;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
import flintstones.model.ui.service.style.ForegroundStyler;
|
||||
|
||||
public class ProblemElementLabelProvider extends LabelProvider implements IStyledLabelProvider {
|
||||
|
||||
@Inject
|
||||
IPhaseMethodService phaseService;
|
||||
|
||||
/** The group image. */
|
||||
private final ImageDescriptor groupImage;
|
||||
|
||||
/** The individual image. */
|
||||
private final ImageDescriptor individualImage;
|
||||
|
||||
/**
|
||||
* Instantiates a new problem element name label provider.
|
||||
*
|
||||
* @param individualImage the individual image
|
||||
* @param groupImage the group image
|
||||
*/
|
||||
public ProblemElementLabelProvider(ImageDescriptor individualImage, ImageDescriptor groupImage) {
|
||||
this.groupImage = groupImage;
|
||||
this.individualImage = individualImage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StyledString getStyledText(Object element) {
|
||||
if (element instanceof ProblemElement) {
|
||||
ProblemElement pe = (ProblemElement) element;
|
||||
StyledString styledString;
|
||||
styledString = paint(pe.getName(), "");
|
||||
|
||||
return styledString;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) */
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if (element instanceof ProblemElement) {
|
||||
if (((ProblemElement) element).hasChildren())
|
||||
return this.groupImage.createImage();
|
||||
|
||||
return this.individualImage.createImage();
|
||||
}
|
||||
|
||||
return super.getImage(element);
|
||||
}
|
||||
|
||||
private StyledString paint(String leftText, String rightText) {
|
||||
|
||||
Color foregroundColorLeft = UiService.COLOR_FG_NORMAL;
|
||||
Color foregroundColorRight = UiService.COLOR_FG_SECONDARY;
|
||||
|
||||
StyledString leftT = new StyledString(leftText, new ForegroundStyler(foregroundColorLeft));
|
||||
StyledString rightT = new StyledString(rightText, new ForegroundStyler(foregroundColorRight));
|
||||
return leftT.append(" ")
|
||||
.append(rightT);
|
||||
}
|
||||
}
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
package flintstones.method.electre.phase.gathering.ui;
|
||||
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Spinner;
|
||||
|
||||
import flintstones.helper.DoubleHelper;
|
||||
import flintstones.method.electre.phase.gathering.ParametersElectre;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
public class ElectreUmbralComponentUI {
|
||||
|
||||
//Textos
|
||||
Label labelIndiferencia;
|
||||
Label labelPreferencia;
|
||||
Label labelVeto;
|
||||
|
||||
//Spinners
|
||||
Spinner indiferencia;
|
||||
Spinner prefrencia;
|
||||
Spinner veto;
|
||||
|
||||
//CheckButtons
|
||||
Button checkButtonVeto;
|
||||
|
||||
boolean changeWeight;
|
||||
|
||||
public ElectreUmbralComponentUI(Composite composite) {
|
||||
changeWeight = false;
|
||||
|
||||
inicializarCompontentes(composite);
|
||||
|
||||
}
|
||||
|
||||
void inicializarCompontentes(Composite base) {
|
||||
Composite row = new Composite(base, 0);
|
||||
UiService.setGridData(row, 0, 9, true, true);
|
||||
UiService.setGridLayout(row, 1);
|
||||
|
||||
//Indiferencia (Q)
|
||||
Composite rowLabelIndiferencia = new Composite(row, 0);
|
||||
UiService.setGridData(rowLabelIndiferencia, 9, 9, true, false);
|
||||
UiService.setGridLayout(rowLabelIndiferencia, 2, true);
|
||||
labelIndiferencia = new Label (rowLabelIndiferencia, SWT.NONE);
|
||||
labelIndiferencia.setText("Indiferencia:");
|
||||
indiferencia = new Spinner (rowLabelIndiferencia, SWT.BORDER);
|
||||
indiferencia.setDigits(3);
|
||||
indiferencia.setMinimum(Integer.MIN_VALUE);
|
||||
indiferencia.setMaximum(Integer.MAX_VALUE);
|
||||
|
||||
//Preferencia (P)
|
||||
Composite rowLabelPreferencia = new Composite(row, 0);
|
||||
UiService.setGridData(rowLabelPreferencia, 9, 9, true, false);
|
||||
UiService.setGridLayout(rowLabelPreferencia, 2, true);
|
||||
labelPreferencia = new Label (rowLabelPreferencia, SWT.NONE);
|
||||
labelPreferencia.setText("Preferencia:");
|
||||
prefrencia = new Spinner (rowLabelPreferencia, SWT.BORDER);
|
||||
prefrencia.setDigits(3);
|
||||
prefrencia.setMinimum(Integer.MIN_VALUE);
|
||||
prefrencia.setMaximum(Integer.MAX_VALUE);
|
||||
|
||||
//Check button Veto
|
||||
Composite rowLabelCheckVeto = new Composite(row, 0);
|
||||
UiService.setGridData(rowLabelCheckVeto, 9, 9, true, false);
|
||||
UiService.setGridLayout(rowLabelCheckVeto, 2, true);
|
||||
checkButtonVeto = new Button(rowLabelCheckVeto, SWT.CHECK);
|
||||
checkButtonVeto.setText("¿Usar veto?");
|
||||
checkButtonVeto.addSelectionListener(new SelectionListener() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
Button btn = (Button) e.getSource();
|
||||
|
||||
veto.setEnabled(btn.getSelection());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//Veto (V)
|
||||
Composite rowLabelVeto = new Composite(row, 0);
|
||||
UiService.setGridData(rowLabelVeto, 9, 9, true, false);
|
||||
UiService.setGridLayout(rowLabelVeto, 2, true);
|
||||
labelVeto = new Label (rowLabelVeto, SWT.NONE);
|
||||
labelVeto.setText("Veto:");
|
||||
veto = new Spinner (rowLabelVeto, SWT.BORDER);
|
||||
veto.setDigits(3);
|
||||
veto.setMinimum(Integer.MIN_VALUE);
|
||||
veto.setMaximum(Integer.MAX_VALUE);
|
||||
veto.setEnabled(false);
|
||||
}
|
||||
|
||||
public void setParametersElectreUI(ParametersElectre dE) {
|
||||
|
||||
//El spinner necesita un entero, entonces transformamos los números con decimales
|
||||
//a numero sin decimales moviendo la coma.
|
||||
|
||||
//Q
|
||||
double oldNumber = dE.getIndiferencia();
|
||||
oldNumber *= Math.pow(10, indiferencia.getDigits());
|
||||
int newNumberWithDecimal = (int) oldNumber;
|
||||
indiferencia.setSelection(newNumberWithDecimal);
|
||||
|
||||
//P
|
||||
oldNumber = dE.getPreferencia();
|
||||
oldNumber *= Math.pow(10, prefrencia.getDigits());
|
||||
newNumberWithDecimal = (int) oldNumber;
|
||||
prefrencia.setSelection(newNumberWithDecimal);
|
||||
|
||||
//CheckButtons
|
||||
checkButtonVeto.setSelection(dE.getUsarVeto());
|
||||
veto.setEnabled(dE.getUsarVeto());
|
||||
oldNumber = dE.getVeto();
|
||||
oldNumber *= Math.pow(10, veto.getDigits());
|
||||
newNumberWithDecimal = (int) oldNumber;
|
||||
veto.setSelection(newNumberWithDecimal);
|
||||
}
|
||||
|
||||
public ParametersElectre getParametersElectreUI() {
|
||||
return new ParametersElectre(
|
||||
this.getValorIndiferencia(),
|
||||
this.getValorPrefrencia(),
|
||||
null, //Direccion
|
||||
0.0, //Peso
|
||||
this.getSiUsarVeto(),
|
||||
this.getValorVeto()
|
||||
);
|
||||
}
|
||||
|
||||
public void addCheckListener(ModifyListener modifyComponent) {
|
||||
//TO-DO
|
||||
}
|
||||
|
||||
public boolean getIsChangeWeight() {
|
||||
return changeWeight;
|
||||
}
|
||||
|
||||
public Label getLabelIndiferencia() {
|
||||
return labelIndiferencia;
|
||||
}
|
||||
|
||||
public Label getLabelPreferencia() {
|
||||
return labelPreferencia;
|
||||
}
|
||||
|
||||
public Label getLabelVeto() {
|
||||
return labelVeto;
|
||||
}
|
||||
|
||||
public Spinner getIndiferencia() {
|
||||
return indiferencia;
|
||||
}
|
||||
|
||||
public Spinner getPrefrencia() {
|
||||
return prefrencia;
|
||||
}
|
||||
|
||||
public Spinner getVeto() {
|
||||
return veto;
|
||||
}
|
||||
|
||||
public Double getValorIndiferencia() {
|
||||
return DoubleHelper.ParseDouble(indiferencia.getText());
|
||||
}
|
||||
|
||||
public Double getValorPrefrencia() {
|
||||
return DoubleHelper.ParseDouble(prefrencia.getText());
|
||||
}
|
||||
|
||||
public Double getValorVeto() {
|
||||
return DoubleHelper.ParseDouble(veto.getText());
|
||||
}
|
||||
|
||||
public Button getCheckButtonVeto() {
|
||||
return checkButtonVeto;
|
||||
}
|
||||
|
||||
public boolean getSiUsarVeto() {
|
||||
return checkButtonVeto.getSelection();
|
||||
}
|
||||
|
||||
public void setTextoIndiferencia(Label labelIndiferencia) {
|
||||
this.labelIndiferencia = labelIndiferencia;
|
||||
}
|
||||
|
||||
public void setTextoPreferencia(String labelPreferencia) {
|
||||
this.labelPreferencia.setText(labelPreferencia);
|
||||
}
|
||||
|
||||
public void setTextoVeto(String labelVeto) {
|
||||
this.labelVeto.setText(labelVeto);
|
||||
}
|
||||
|
||||
}
|
||||
+359
@@ -0,0 +1,359 @@
|
||||
package flintstones.method.electre.phase.gathering.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||
import org.eclipse.jface.viewers.ICheckStateListener;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import flintstones.application.perspective.framework.ui.interfaces.IProblemElementViewerOnSingleClick;
|
||||
import flintstones.application.perspective.framework.ui.viewer.ProblemElementViewer;
|
||||
import flintstones.entity.method.phase.ui.PhaseMethodUI;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.FakeProblemElement;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.helper.html.table.HtmlTextTable;
|
||||
import flintstones.method.common.phase.aggregation.provider.ProblemElementAggregationCheckStateProvider;
|
||||
import flintstones.method.electre.phase.gathering.ParametersElectre;
|
||||
import flintstones.method.electre.phase.gathering.Electre3Method;
|
||||
import flintstones.method.electre.phase.gathering.viewer.ProblemElementViewerLabel;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
public class PhaseElectreUI extends PhaseMethodUI implements IProblemElementViewerOnSingleClick, ICheckStateListener {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
Electre3Method electre;
|
||||
|
||||
//Component parameters ui
|
||||
int selectedIndex;
|
||||
ArrayList<ParametersElectre> parametersElectre;
|
||||
ElectreUmbralComponentUI electreComponent;
|
||||
boolean isExecutableElectre;
|
||||
ArrayList<Boolean> excuteElectre;
|
||||
|
||||
HtmlTextTable tableValuesAlternative;
|
||||
Label titleLabelParametersCriterion;
|
||||
|
||||
ProblemElementViewer criterionViewer;
|
||||
ProblemElementAggregationCheckStateProvider checkProvider;
|
||||
|
||||
//Parameters electre
|
||||
Expert expertProblem;
|
||||
String selectedCriterion;
|
||||
|
||||
Button btnPasarFase;
|
||||
|
||||
//Listener for the UI components.
|
||||
ModifyListener modifyP = new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
parametersElectre.get(selectedIndex).setPeso(electreComponent.getValorPrefrencia());
|
||||
//Cambiamos la col1
|
||||
criterionViewer.updateViewer(Criterion.Type);
|
||||
}
|
||||
};
|
||||
|
||||
ModifyListener modifyQ = new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
parametersElectre.get(selectedIndex).setPreferencia(electreComponent.getValorPrefrencia());
|
||||
//Cambiamos la col1
|
||||
criterionViewer.updateViewer(Criterion.Type);
|
||||
}
|
||||
};
|
||||
|
||||
ModifyListener modifyS = new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
parametersElectre.get(selectedIndex).setPeso(electreComponent.getValorPrefrencia());
|
||||
//Cambiamos la col1
|
||||
criterionViewer.updateViewer(Criterion.Type);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
isExecutableElectre = false;
|
||||
electre = (Electre3Method) this.getModel();
|
||||
electre.inicializar();
|
||||
|
||||
//Inicializar datos
|
||||
Composite base = this.getBaseComposite();
|
||||
UiService.setGridData(base, 9, 9, true, true);
|
||||
UiService.setGridLayout(base, 1);
|
||||
|
||||
Composite row1 = new Composite(base, 0);
|
||||
UiService.setGridData(row1, 9, 0, true, false);
|
||||
UiService.setGridLayout(row1, 1);
|
||||
|
||||
Label titleLabel = new Label(row1, SWT.NONE);
|
||||
titleLabel.setText("Fase datos umbrales Electre 3");
|
||||
UiService.setGridData(titleLabel, 9 ,9, true, false);
|
||||
UiService.setFont(titleLabel, UiService.FONT_SECTION_TITLE);
|
||||
|
||||
//BODY
|
||||
Composite row2 = new Composite(base, 0);
|
||||
UiService.setGridData(row2, 9,9, true, true);
|
||||
UiService.setGridLayout(row2, 3, true);
|
||||
|
||||
expertProblem = electre.getExperts()[0];
|
||||
selectedCriterion = electre.getCriterion()[0].getCanonicalName();
|
||||
initBodyUI(row2);
|
||||
|
||||
//Button
|
||||
Composite row3 = new Composite(base, 0);
|
||||
UiService.setGridData(row3, 0,9, true, true);
|
||||
UiService.setGridLayout(row3, 1);
|
||||
|
||||
btnPasarFase = new Button(row3, 0);
|
||||
btnPasarFase.setText("Obtener resultados");
|
||||
btnPasarFase.addSelectionListener(new SelectionListener() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
saveParameters();
|
||||
|
||||
//q <= p <= v ??
|
||||
for(int i = 0; i < parametersElectre.size(); i++) {
|
||||
if(parametersElectre.get(i).getIndiferencia() > parametersElectre.get(i).getPreferencia() ||
|
||||
(parametersElectre.get(i).getPreferencia() > parametersElectre.get(i).getVeto() && parametersElectre.get(i).getUsarVeto())) {
|
||||
pushProblemDialog("Se debe cumplir que: indiferencia <= preferencia <= veto");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
executeElectre();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initBodyUI(Composite base) {
|
||||
parametersElectre = new ArrayList<ParametersElectre>();
|
||||
excuteElectre = new ArrayList<Boolean>();
|
||||
initArrayDatosElectre();
|
||||
selectedIndex = 0;
|
||||
|
||||
createColTreeView(base);
|
||||
|
||||
createColParametersElectre(base);
|
||||
|
||||
createColTableAlternative(base);
|
||||
|
||||
//electreComponent.addCheckListener(modifyComponent);
|
||||
}
|
||||
|
||||
private void createColTreeView(Composite base) {
|
||||
|
||||
Composite row = new Composite(base, 0);
|
||||
UiService.setGridData(row, 9, 9, true, true);
|
||||
UiService.setGridLayout(row, 1);
|
||||
|
||||
Label titleLabel = new Label(row, SWT.NONE);
|
||||
titleLabel.setText("Criterios");
|
||||
UiService.setGridData(titleLabel, 9 ,9, true, false);
|
||||
UiService.setFont(titleLabel, UiService.FONT_SECTION_TITLE);
|
||||
|
||||
//Criterion tree
|
||||
criterionViewer = getViewer(row, Criterion.Type, true);
|
||||
}
|
||||
|
||||
private void createColParametersElectre(Composite base) {
|
||||
Composite row = new Composite(base, 0);
|
||||
UiService.setGridData(row, 9, 9, true, true);
|
||||
UiService.setGridLayout(row, 1);
|
||||
|
||||
titleLabelParametersCriterion = new Label(row, SWT.NONE);
|
||||
titleLabelParametersCriterion.setText("Umbrales de " + selectedCriterion);
|
||||
UiService.setGridData(titleLabelParametersCriterion, 9 ,9, true, false);
|
||||
UiService.setFont(titleLabelParametersCriterion, UiService.FONT_SECTION_TITLE);
|
||||
|
||||
Composite row1 = new Composite(row, SWT.BORDER);
|
||||
UiService.setGridData(row1, 9, 9, true, true);
|
||||
UiService.setGridLayout(row1, 1);
|
||||
|
||||
electreComponent = new ElectreUmbralComponentUI(row1);
|
||||
electreComponent.setParametersElectreUI( parametersElectre.get(selectedIndex) );
|
||||
|
||||
}
|
||||
|
||||
private void createColTableAlternative(Composite base) {
|
||||
Composite row = new Composite(base, 0);
|
||||
UiService.setGridData(row, 9, 9, true, true);
|
||||
UiService.setGridLayout(row, 1);
|
||||
|
||||
Label titleLabel = new Label(row, SWT.NONE);
|
||||
titleLabel.setText("Datos alternativa");
|
||||
UiService.setGridData(titleLabel, 9 ,9, true, false);
|
||||
UiService.setFont(titleLabel, UiService.FONT_SECTION_TITLE);
|
||||
|
||||
Composite row1 = new Composite(row, SWT.BORDER);
|
||||
UiService.setGridData(row1, 9, 9, true, true);
|
||||
UiService.setGridLayout(row1, 1);
|
||||
|
||||
initTableAlternative(row1, electre.getAlernativesNames(), electre.getCriterionNames());
|
||||
}
|
||||
|
||||
private void initTableAlternative(Composite base, String[] alternativesNames, String[] criterions) {
|
||||
String[][] valuesCriterionAlternatives = new String[alternativesNames.length][1];
|
||||
String[] nameCriterion = new String[1];
|
||||
nameCriterion[0] = selectedCriterion;
|
||||
|
||||
int indexCriterion = -1;
|
||||
for(int i = 0; i < criterions.length; i++) {
|
||||
if( criterions[i].equals(selectedCriterion) ){
|
||||
indexCriterion = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double[][] values = electre.getValuations(expertProblem);
|
||||
for(int i = 0; i < values.length; i++) {
|
||||
valuesCriterionAlternatives [i][0] = Double.toString(values[i][indexCriterion]);
|
||||
}
|
||||
|
||||
this.tableValuesAlternative = new HtmlTextTable(base, valuesCriterionAlternatives, nameCriterion, alternativesNames);
|
||||
this.tableValuesAlternative.render();
|
||||
}
|
||||
|
||||
private void initArrayDatosElectre() {
|
||||
for(int i = 0; i < electre.getCriterion().length; i++) {
|
||||
parametersElectre.add( new ParametersElectre(0.0, 0.0, ParametersElectre.Direccion.maximizar, 0.0, false, 0.0) );
|
||||
excuteElectre.add(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void executeElectre() {
|
||||
for(int i = 0; i < parametersElectre.size(); i++) {
|
||||
ParametersElectre pE = parametersElectre.get(i);
|
||||
pE.setCriterion(electre.getCriterion()[i]);
|
||||
electre.addDatoEntrada(pE);
|
||||
}
|
||||
|
||||
electre.executeMethod(electre.getExperts()[0]);
|
||||
isExecutableElectre = true;
|
||||
refreshUI();
|
||||
}
|
||||
|
||||
//Métodos para el Tree View
|
||||
private ProblemElementViewer getViewer(Composite parent, String type, boolean addParent) {
|
||||
|
||||
ProblemElementViewerLabel viewer = ContextInjectionFactory.make(ProblemElementViewerLabel.class, this.context);
|
||||
|
||||
if (addParent) {
|
||||
FakeProblemElement fakePE = new FakeProblemElement("");
|
||||
fakePE.as(type);
|
||||
viewer.useGlobalParent(fakePE);
|
||||
}
|
||||
|
||||
viewer.createControls(type, parent);
|
||||
viewer.addListener(this);
|
||||
viewer.loadListeners();
|
||||
|
||||
UiService.setGridLayout(viewer.getTree().getTree(), 1);
|
||||
UiService.setGridData(viewer.getTree().getTree(), 9, 9, true, true);
|
||||
|
||||
return viewer;
|
||||
}
|
||||
|
||||
public void problemElementViewerOnSingleClick(ProblemElement item) {
|
||||
//Seleccionado el fake parent.
|
||||
if(item.getCanonicalName().equals(""))
|
||||
return;
|
||||
|
||||
//Guardamos
|
||||
saveParameters();
|
||||
|
||||
selectedCriterion = item.getCanonicalName();
|
||||
titleLabelParametersCriterion.setText("Umbrales de " + selectedCriterion);
|
||||
|
||||
//Cambiamos col 2
|
||||
for(int i = 0; i < electre.getCriterion().length; i++) {
|
||||
if( electre.getCriterion()[i].getCanonicalName().equals(selectedCriterion) ){
|
||||
selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
electreComponent.setParametersElectreUI( parametersElectre.get(selectedIndex) );
|
||||
|
||||
//Cambiamos col3
|
||||
refreshValuesAlternative();
|
||||
}
|
||||
|
||||
public void checkStateChanged(CheckStateChangedEvent event) {
|
||||
refreshUI();
|
||||
}
|
||||
|
||||
private void saveParameters() {
|
||||
//Actualizarmos el valor.
|
||||
parametersElectre.get(selectedIndex).setIndiferencia(electreComponent.getValorIndiferencia());
|
||||
parametersElectre.get(selectedIndex).setPreferencia(electreComponent.getValorPrefrencia());
|
||||
parametersElectre.get(selectedIndex).setUsarVeto(electreComponent.getSiUsarVeto());
|
||||
parametersElectre.get(selectedIndex).setVeto(electreComponent.getValorVeto());
|
||||
}
|
||||
|
||||
private void refreshValuesAlternative() {
|
||||
|
||||
if(tableValuesAlternative == null) return;
|
||||
|
||||
Composite row = tableValuesAlternative.getParent();
|
||||
Arrays.stream(row.getChildren()).forEach(k -> k.dispose());
|
||||
|
||||
initTableAlternative(row, electre.getAlernativesNames(), electre.getCriterionNames());
|
||||
|
||||
tableValuesAlternative.render();
|
||||
row.layout();
|
||||
}
|
||||
|
||||
private void pushProblemDialog(String msg) {
|
||||
Shell newShell = new Shell();
|
||||
UiService.centerShell(newShell, true);
|
||||
MessageDialog.openError(newShell, "Error", msg);
|
||||
}
|
||||
|
||||
public void refreshUI() {
|
||||
this.sendRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForwardEnabled() {
|
||||
if(isExecutableElectre)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package flintstones.method.electre.phase.gathering.viewer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
|
||||
|
||||
import flintstones.application.perspective.framework.ui.viewer.ProblemElementViewer;
|
||||
import flintstones.entity.problemelement.entities.ProblemElementHelper;
|
||||
import flintstones.method.electre.phase.gathering.provider.ProblemElementLabelProvider;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
public class ProblemElementViewerLabel extends ProblemElementViewer {
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Override
|
||||
protected IStyledLabelProvider getLabelProvider(String type) {
|
||||
|
||||
ImageDescriptor individualImage = UiService.getIcon(ProblemElementHelper.getImage(type, false));
|
||||
ImageDescriptor groupImage = UiService.getIcon(ProblemElementHelper.getImage(type, true));
|
||||
|
||||
ProblemElementLabelProvider provider = new ProblemElementLabelProvider(individualImage, groupImage);
|
||||
ContextInjectionFactory.inject(provider, context);
|
||||
return provider;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user