public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -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.destillation.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.destillation.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>1779484362663</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>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -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
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: flintstones.method.electre.phase.destillation.gathering.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.method.electre.phase.destillation.gathering.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.e4.core.contexts,
flintstones.entity.problemelement,
flintstones.helper.html,
flintstones.method.electre.phase.destillation.gathering,
flintstones.entity.method.phase.ui,
javax.inject,
org.eclipse.swt,
flintstones.model.ui.service,
flintstones.helper.data,
flintstones.entity.method.phase
@@ -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.destillation.gathering.ui"
implementation="flintstones.method.electre.phase.destillation.gathering.ui.DestillationUI"
phasemethod="flintstones.method.electre.phase.destillation.gathering">
</phasemethod_ui>
</extension>
</plugin>
@@ -0,0 +1,309 @@
package flintstones.method.electre.phase.destillation.gathering.ui;
import java.util.Arrays;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
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.Spinner;
import flintstones.entity.method.phase.ui.PhaseMethodUI;
import flintstones.entity.problemelement.entities.Alternative;
import flintstones.helper.DoubleHelper;
import flintstones.helper.html.table.HtmlTextTable;
import flintstones.method.electre.phase.destillation.gathering.DestillationModel;
import flintstones.model.ui.service.UiService;
public class DestillationUI extends PhaseMethodUI {
@Inject
IEclipseContext context;
DestillationModel destillationModel;
Alternative[] alts;
double[][] fuzzyRelation; // Alternativas frente alternativas
HtmlTextTable tableAsc;
HtmlTextTable tableFinalRanking;
HtmlTextTable tableDesc;
Button checkButtonDefault;
Spinner spinnerAlfa;
Spinner spinnerBeta;
Composite rowTables;
//Listener for the UI components.
ModifyListener modifyComponent = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
Spinner alf = (Spinner) e.getSource();
Spinner bet = (Spinner) e.getSource();
String alfaText = alf.getText();
String betaText = bet.getText();
if(alfaText != null || betaText != null)
if(!alfaText.equals("") || !betaText.equals(""))
refreshTable();
}
};
@Override
public void init() {
destillationModel = (DestillationModel) this.getModel();
destillationModel.importarDatos();
//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);
//buttons destillation
createButtonDestillation(base);
//Mostrar matriz final
alts = destillationModel.getAlternativas();
double alfa = DoubleHelper.ParseDouble(spinnerAlfa.getText());
double beta = DoubleHelper.ParseDouble(spinnerBeta.getText());
destillationModel.executeDestillation(alfa, beta);
Composite row2 = new Composite(base, 0);
UiService.setGridData(row2, 9, 9, true, false);
UiService.setGridLayout(row2, 3, true);
initTitleTables(row2);
rowTables = new Composite(base, 0);
UiService.setGridData(rowTables, 9, 9, true, true);
UiService.setGridLayout(rowTables, 3, true);
initBody(rowTables);
}
private void initTitleTables(Composite base) {
Label titleAsc = new Label(base, SWT.NONE);
titleAsc.setText("Ranking Ascendente");
UiService.setGridData(titleAsc, 0 ,9, true, false);
UiService.setFont(titleAsc, UiService.FONT_SECTION_TITLE);
Label titleDes = new Label(base, SWT.NONE);
titleDes.setText("Ranking Descendente");
UiService.setGridData(titleDes, 0 ,9, true, false);
UiService.setFont(titleDes, UiService.FONT_SECTION_TITLE);
Label titleFinal = new Label(base, SWT.NONE);
titleFinal.setText("Ranking Final");
UiService.setGridData(titleFinal, 0 ,9, true, false);
UiService.setFont(titleFinal, UiService.FONT_SECTION_TITLE);
}
private void initBody(Composite base) {
Composite row1 = new Composite(base, 0);
UiService.setGridData(row1, 9, 9, true, true);
UiService.setGridLayout(row1, 1);
createColDes(row1, destillationModel.getRankingDes(), destillationModel.getAlternativasNames());
Composite row2 = new Composite(base, 0);
UiService.setGridData(row2, 9, 9, true, true);
UiService.setGridLayout(row2, 1);
createColAsc(row2, destillationModel.getRankingAsc(), destillationModel.getAlternativasNames());
Composite row3 = new Composite(base, 0);
UiService.setGridData(row3, 9, 9, true, true);
UiService.setGridLayout(row3, 1);
createColFinal(row3, destillationModel.getFinalRanking(), destillationModel.getAlternativasNames());
}
private void createButtonDestillation(Composite base) {
Composite row = new Composite(base, 0);
UiService.setGridData(row, 0, 9, true, false);
UiService.setGridLayout(row, 1);
//Check button Veto
Composite rowLabelCheckVeto = new Composite(row, 0);
UiService.setGridData(rowLabelCheckVeto, 0, 9, true, false);
UiService.setGridLayout(rowLabelCheckVeto, 1);
checkButtonDefault = new Button(rowLabelCheckVeto, SWT.CHECK);
checkButtonDefault.setText("Usar valores por defecto");
checkButtonDefault.setSelection(true);
checkButtonDefault.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
Button btn = (Button) e.getSource();
spinnerAlfa.setEnabled(!btn.getSelection());
spinnerBeta.setEnabled(!btn.getSelection());
if(btn.getSelection()) {
spinnerAlfa.setSelection(-15);
spinnerBeta.setSelection(30);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
});
Composite row2 = new Composite(row, 0);
UiService.setGridData(row2, 0, 9, true, false);
UiService.setGridLayout(row2, 2, true);
//Indiferencia (Q)
Composite rowLabelAlfa = new Composite(row2, 0);
UiService.setGridData(rowLabelAlfa, 9, 9, true, false);
UiService.setGridLayout(rowLabelAlfa, 2);
Label labelAlfa = new Label (rowLabelAlfa, SWT.NONE);
labelAlfa.setText("Alfa:");
spinnerAlfa = new Spinner (rowLabelAlfa, SWT.BORDER);
spinnerAlfa.setDigits(2);
spinnerAlfa.setMinimum(Integer.MIN_VALUE);
spinnerAlfa.setMaximum(Integer.MAX_VALUE);
spinnerAlfa.setEnabled(false);
spinnerAlfa.setSelection(-15);
spinnerAlfa.addModifyListener(modifyComponent);
//Preferencia (P)
Composite rowLabelBeta = new Composite(row2, 0);
UiService.setGridData(rowLabelBeta, 9, 9, true, false);
UiService.setGridLayout(rowLabelBeta, 2);
Label labelBeta = new Label (rowLabelBeta, SWT.NONE);
labelBeta.setText("Beta:");
spinnerBeta = new Spinner (rowLabelBeta, SWT.BORDER);
spinnerBeta.setDigits(2);
spinnerBeta.setMinimum(Integer.MIN_VALUE);
spinnerBeta.setMaximum(Integer.MAX_VALUE);
spinnerBeta.setEnabled(false);
spinnerBeta.setSelection(30);
spinnerBeta.addModifyListener(modifyComponent);
}
private void createColAsc(Composite base, int[] ranking, String[] alternativas) {
String[] rankingNames = new String [alternativas.length];
String[] rankingNumber = new String [alternativas.length];
int indiceRanking = 0;
int indiceArray = 0;
while(indiceArray < alternativas.length) {
for(int j = 0; j < ranking.length; j++) {
if(ranking[j] == indiceRanking) {
rankingNames[indiceArray] = alternativas[j];
rankingNumber[indiceArray] = Integer.toString(indiceRanking);
indiceArray++;
}
}
indiceRanking++;
}
tableAsc = new HtmlTextTable(base, rankingNames, rankingNumber, true);
tableAsc.render();
}
private void createColFinal(Composite base, int[] ranking, String[] alternativas) {
String[] rankingNames = new String [alternativas.length];
String[] rankingNumber = new String [alternativas.length];
int indiceRanking = 0;
int indiceArray = 0;
while(indiceArray < alternativas.length) {
for(int j = 0; j < ranking.length; j++) {
if(ranking[j] == indiceRanking) {
rankingNames[indiceArray] = alternativas[j];
rankingNumber[indiceArray] = Integer.toString(indiceRanking);
indiceArray++;
}
}
indiceRanking++;
}
tableFinalRanking = new HtmlTextTable(base, rankingNames, rankingNumber,true);
tableFinalRanking.render();
}
private void createColDes(Composite base, int[] ranking, String[] alternativas) {
String[] rankingNames = new String [alternativas.length];
String[] rankingNumber = new String [alternativas.length];
int indiceRanking = 0;
int indiceArray = 0;
while(indiceArray < alternativas.length) {
for(int j = 0; j < ranking.length; j++) {
if(ranking[j] == indiceRanking) {
rankingNames[indiceArray] = alternativas[j];
rankingNumber[indiceArray] = Integer.toString(indiceRanking);
indiceArray++;
}
}
indiceRanking++;
}
tableDesc = new HtmlTextTable(base, rankingNames, rankingNumber, true);
tableDesc.render();
}
private void refreshTable() {
if(rowTables == null) return;
Arrays.stream(rowTables.getChildren()).forEach(k -> k.dispose());
destillationModel.importarDatos();
double alfa = DoubleHelper.ParseDouble(spinnerAlfa.getText());
double beta = DoubleHelper.ParseDouble(spinnerBeta.getText());
destillationModel.executeDestillation(alfa, beta);
initBody(rowTables);
tableAsc.render();
tableFinalRanking.render();
tableDesc.render();
rowTables.layout();
}
@Override
public void refresh() {
refreshTable();
this.sendRefresh();
}
@Override
public boolean isSkippable() {
return false;
}
@Override
public boolean isForwardEnabled() {
return false;
}
}