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.ahp.sort.phase.ranking.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.ahp.sort.phase.ranking.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>1779484362630</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,26 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: flintstones.method.ahp.sort.phase.ranking.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.method.ahp.sort.phase.ranking.ui
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: flintstones.method.ahp.sort.phase.ranking,
org.eclipse.swt,
flintstones.model.ahppreferences.service,
javax.inject,
flintstones.helper.ui,
org.eclipse.e4.core.contexts,
flintstones.helper.html,
flintstones.entity.problemelement,
flintstones.model.problemelement.service,
flintstones.model.ahpsort.profileassignment.service,
flintstones.entity.ahpsort.profileassignment,
flintstones.model.domain.service,
flintstones.entity.domain,
flintstones.helper.data,
org.apache.commons.lang,
flintstones.model.ui.service,
flintstones.entity.method.phase,
flintstones.entity.method.phase.ui,
flintstones.entity.problemelement.ui
@@ -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.ahp.sort.phase.ranking.ui"
implementation="flintstones.method.ahp.sort.phase.ranking.ui.AHPSortRankingUI"
phasemethod="flintstones.method.ahp.sort.phase.ranking">
</phasemethod_ui>
</extension>
</plugin>
@@ -0,0 +1,473 @@
package flintstones.method.ahp.sort.phase.ranking.ui;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import flintstones.entity.method.phase.ui.PhaseMethodUI;
import flintstones.entity.problemelement.entities.Alternative;
import flintstones.entity.problemelement.entities.Criterion;
import flintstones.entity.problemelement.entities.Expert;
import flintstones.entity.problemelement.entities.ProblemElement;
import flintstones.entity.problemelement.entities.ProblemElementHelper;
import flintstones.entity.problemelement.entities.SortingClass;
import flintstones.entity.problemelement.entities.SortingProfile;
import flintstones.entity.problemelement.ui.widget.ProblemElementSelector;
import flintstones.entity.problemelement.ui.widget.listener.IProblemElementChangedListener;
import flintstones.helper.DoubleHelper;
import flintstones.helper.MapHelper;
import flintstones.helper.MatrixHelper;
import flintstones.helper.data.HashMatrix;
import flintstones.helper.html.table.HtmlTextTable;
import flintstones.method.ahp.sort.phase.ranking.AHPSortRankingModel;
import flintstones.model.ahpsort.profileassignment.service.IProfileAssignmentService;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.ui.service.UiService;
/**
* The Class AHPSortRankingUI.
*/
public class AHPSortRankingUI extends PhaseMethodUI {
boolean isCentralx = false;
/** The model. */
AHPSortRankingModel model;
/** The context. */
@Inject
IEclipseContext context;
/** The problem service. */
@Inject
IProblemElementService problemService;
/** The profile service. */
@Inject
IProfileAssignmentService profileService;
/** The domain service. */
@Inject
IDomainService domainService;
/** The criterion profiles table. */
//HtmlTextTable criterionProfilesTable;
/** The result table. */
HtmlTextTable resultTable;
/** The alternatives table. */
HtmlTextTable alternativesTable;
/** The profiles table. */
HtmlTextTable profilesTable;
/** The criterion weights table. */
HtmlTextTable criterionWeightsTable;
/** The current expert. */
Expert currentExpert;
/* (non-Javadoc)
* @see flintstones.phasemethod.ui.PhaseMethodUI#init()
*/
@Override
public void init() {
model = (AHPSortRankingModel) this.getModel();
model.execute();
createPartControls(this.getBaseComposite());
}
/* (non-Javadoc)
* @see flintstones.phasemethod.ui.PhaseMethodUI#refresh()
*/
@Override
public void refresh() {
}
/* (non-Javadoc)
* @see flintstones.phasemethod.ui.PhaseMethodUI#isForwardEnabled()
*/
@Override
public boolean isForwardEnabled() {
return true;
}
/**
* Creates the part controls.
*
* @param parent the parent
*/
public void createPartControls(Composite parent) {
isCentralx = profileService.getType().equals(SortingProfile.SortingProfileType.Central);
UiService.setGridData(parent, 9, 9, true, true);
UiService.setGridLayout(parent, 1);
createConfigurationRow(parent);
Composite cols = new Composite(parent, 0);
UiService.setGridData(cols, 9, 9, true, true);
UiService.setGridLayout(cols, 2);
Composite col0 = new Composite(cols,0);
UiService.setGridData(col0, 9, 9, true, true);
UiService.setGridLayout(col0, 1);
createCriterionWeightsCol(col0);
//createCriterionProfilesCol(col0);
createAlternativesCol(col0);
createProfilesCol(col0);
Composite col1 = new Composite(cols,0);
UiService.setGridData(col1, 9, 9, true, true);
UiService.setGridLayout(col1, 1);
createResultRow(col1);
}
/**
* Refresh tables.
*/
private void refreshTables() {
this.createWeightsTable(criterionWeightsTable.getParent());
//this.createCriterionProfileTable(criterionProfilesTable.getParent());
this.createAlternativesTable(alternativesTable.getParent());
this.createProfilesTable(profilesTable.getParent());
this.createResultTable(resultTable.getParent());
}
/**
* Creates the criterion profiles col.
*
* @param parent the parent
*/
/*private void createCriterionProfilesCol(Composite parent) {
Composite base = new Composite(parent,0);
UiService.setGridData(base, 9, 9, true, true);
UiService.setGridLayout(base, 1);
Label title = new Label(base, 0);
title.setText("Sorting profiles");
UiService.setGridData(title, -1, 0, true, false);
UiService.setFont(title, UiService.FONT_SECTION_TITLE);
Composite tableBase = new Composite(base,0);
UiService.setGridData(tableBase, 9, 9, true, true);
UiService.setGridLayout(tableBase, 1);
createCriterionProfileTable(tableBase);
}*/
/**
* Creates the criterion profile table.
*
* @param tableBase the table base
*/
/*private void createCriterionProfileTable(Composite tableBase) {
ProblemElement[] criteria = problemService.getAll(Criterion.Type);
criteria = ProblemElementHelper.getAsUserOrdered(criteria);
ProfileAssignment[] assignments = new ProfileAssignment[criteria.length];
for(int i = 0; i < criteria.length; i++) {
ProblemElement c = criteria[i];
ProfileAssignment assignment = profileService.get(getCurrentExpert(), (Criterion) c);
assignments[i] = assignment;
}
String[] vHeaders = Arrays.stream(criteria).map(k -> k.getName()).toArray(String[]::new);
String[] hHeaders = Arrays.stream(model.getClasses()).map(k -> k.getName()).toArray(String[]::new);
if(!profileService.getType().equals(SortingProfile.SortingProfileType.Central))
hHeaders = Arrays.copyOfRange(hHeaders, 0, hHeaders.length - 1);
String[][] values = new String[vHeaders.length][hHeaders.length];
int numProfiles = problemService.getAll(SortingProfile.Type).length / criteria.length;
for(int i = 0; i < assignments.length; i++) {
ProfileAssignment assignment = assignments[i];
String[] rowValues = new String[numProfiles];
for(int prof = 0; prof < numProfiles; ++prof)
rowValues[prof] = assignment.getValues()[prof].toString();
values[i] = rowValues;
}
criterionProfilesTable = new HtmlTextTable(tableBase, values, hHeaders, vHeaders);
criterionProfilesTable.render();
}*/
/**
* Creates the configuration row.
*
* @param parent the parent
*/
private void createConfigurationRow(Composite parent) {
Composite row = new Composite(parent,0);
UiService.setGridData(row, 9, 0, true, false);
UiService.setGridLayout(row, 1);
Label title = new Label(row, 0);
title.setText("Options");
UiService.setGridData(title, -1, 0, true, false);
UiService.setFont(title, UiService.FONT_SECTION_TITLE);
ProblemElement[] experts = problemService.getAll(Expert.Type);
ProblemElementSelector selector = new ProblemElementSelector(row,experts );
selector.setListener(new IProblemElementChangedListener() {
public void problemElementChanged(ProblemElement pe) {
setCurrentExpert(pe);
refreshTables();
}
});
setCurrentExpert(selector.getSelectedElement());
}
/**
* Creates the criterion weights col.
*
* @param parent the parent
*/
private void createCriterionWeightsCol(Composite parent) { // X
Composite base = new Composite(parent,0);
UiService.setGridData(base, 9, 9, true, true);
UiService.setGridLayout(base, 1);
Label title = new Label(base, 0);
title.setText("Criteria weight");
UiService.setGridData(title, -1, 0, true, false);
UiService.setFont(title, UiService.FONT_SECTION_TITLE);
Composite tableBase = new Composite(base,0);
UiService.setGridData(tableBase, 9, 9, true, true);
UiService.setGridLayout(tableBase, 1);
createWeightsTable(tableBase);
}
/**
* Creates the weights table.
*
* @param tableBase the table base
*/
private void createWeightsTable(Composite tableBase) { // X
ProblemElement[] criteria = problemService.getAll(Criterion.Type);
Map<ProblemElement,Double> map = model.getCriterionWeightsFor(getCurrentExpert());
LinkedHashMap<ProblemElement, Double> criterionWeights = MapHelper.sortByExample(map, criteria);
String[] vHeaders = criterionWeights.keySet().stream().map(k -> k.getName()).toArray(String[]::new);
String[] hHeaders = new String[] {"Weight"};
String[][] values = new String[criteria.length][1];
int cont = 0;
for(ProblemElement crit: criterionWeights.keySet()) {
values[cont][0] = DoubleHelper.Draw(criterionWeights.get(crit));
cont++;
}
criterionWeightsTable = new HtmlTextTable(tableBase, values, hHeaders, vHeaders);
criterionWeightsTable.render();
}
/**
* Creates the alternatives col.
*
* @param parent the parent
*/
private void createAlternativesCol(Composite parent) {
Composite base = new Composite(parent,0);
UiService.setGridData(base, 9, 9, true, true);
UiService.setGridLayout(base, 1);
Label title = new Label(base, 0);
title.setText("Alternatives global priorities");
UiService.setGridData(title, -1, 0, true, false);
UiService.setFont(title, UiService.FONT_SECTION_TITLE);
// Build Table
Composite tableBase = new Composite(base,0);
UiService.setGridData(tableBase, 9, 9, true, true);
UiService.setGridLayout(tableBase, 1);
createAlternativesTable(tableBase);
}
/**
* Creates the alternatives table.
*
* @param tableBase the table base
*/
private void createAlternativesTable(Composite tableBase) {
// DATA
HashMatrix<ProblemElement, Integer, Double> alternativePriorities = model.getAlternativeGlobalPrioritiesFor(getCurrentExpert());
// FORMAT into TABLE
String[] vHeaders = alternativePriorities.keySet().stream().map(k -> k.getName()).toArray(String[]::new);
String[] hHeaders = alternativePriorities.values().iterator().next().keySet().stream().map(k ->"Priority").toArray(String[]::new);
String[][] valuesD = new String[vHeaders.length][hHeaders.length];
int i = 0;
for(ProblemElement a : alternativePriorities.keySet()) {
for(int j = 0; j < hHeaders.length; j++) {
int jj = j;
valuesD[i][j] = DoubleHelper.Draw(alternativePriorities.get(a,jj));
}
i++;
}
alternativesTable = new HtmlTextTable(tableBase, valuesD, hHeaders, vHeaders);
alternativesTable.render();
}
/**
* Creates the profiles col.
*
* @param parent the parent
*/
private void createProfilesCol(Composite parent) {
Composite base = new Composite(parent,0);
UiService.setGridData(base, 9, 9, true, true);
UiService.setGridLayout(base, 1);
Label title = new Label(base, 0);
title.setText("Profiles global priorities");
UiService.setGridData(title, -1, 0, true, false);
UiService.setFont(title, UiService.FONT_SECTION_TITLE);
Composite tableBase = new Composite(base,0);
UiService.setGridData(tableBase, 9, 9, true, true);
UiService.setGridLayout(tableBase, 1);
createProfilesTable(tableBase);
}
/**
* Creates the profiles table.
*
* @param tableBase the table base
*/
private void createProfilesTable(Composite tableBase) {
HashMatrix<Integer, Alternative, Double> profilePriorities = model.getProfileGlobalPrioritiesFor(getCurrentExpert());
ProblemElement[] criteria = problemService.getAll(Criterion.Type);
int numProfiles = problemService.getAll(SortingProfile.Type).length / criteria.length;
Integer[] profiles = profilePriorities.keySet().stream().toArray(Integer[]::new);
Alternative[] alternatives = profilePriorities.values().iterator().next().keySet().stream().toArray(Alternative[]::new);
String[] hHeaders = Arrays.stream(model.getClasses()).map(k -> k.getName()).toArray(String[]::new);
if(!profileService.getType().equals(SortingProfile.SortingProfileType.Central))
hHeaders = Arrays.copyOfRange(hHeaders, 0, hHeaders.length - 1);
String[] vHeaders = Arrays.stream(alternatives).map(k -> k.getName()).toArray(String[]::new);
String[][] valuesD = new String[numProfiles][alternatives.length];
for(int i = 0; i < numProfiles; i++) {
for(int j = 0; j < alternatives.length; j++) {
valuesD[i][j] = DoubleHelper.Draw(profilePriorities.get(profiles[i], alternatives[j]));
}
}
valuesD = MatrixHelper.transpose(valuesD);
profilesTable = new HtmlTextTable(tableBase, valuesD, hHeaders, vHeaders);
profilesTable.render();
}
/**
* Creates the result row.
*
* @param base the base
*/
private void createResultRow(Composite base) {
Label title = new Label(base, 0);
title.setText("Classified classes");
UiService.setGridData(title, -1, 0, true, false);
UiService.setFont(title, UiService.FONT_SECTION_TITLE);
Composite tableBase = new Composite(base,0);
UiService.setGridData(tableBase, 9, 9, true, true);
UiService.setGridLayout(tableBase, 1);
createResultTable(tableBase);
}
/**
* Creates the result table.
*
* @param tableBase the table base
*/
private void createResultTable(Composite tableBase) {
HashMap<ProblemElement,SortingClass> map = model.getClassificationFor(getCurrentExpert());
ProblemElement[] alternatives = ProblemElementHelper.getAsUserOrdered(problemService.getAll(Alternative.Type));
LinkedHashMap<ProblemElement, SortingClass> sortedMap = MapHelper.sortByExample(map, alternatives);
String[] vHeaders = sortedMap.keySet().stream().map(k -> k.getName()).toArray(String[]::new);
String[] hHeaders = new String[] {"Class"};
String[][] values = new String[alternatives.length][1];
int cont = 0;
for(ProblemElement alt: sortedMap.keySet()) {
values[cont][0] = sortedMap.get(alt).getName();
cont++;
}
resultTable = new HtmlTextTable(tableBase, values, hHeaders, vHeaders);
resultTable.render();
}
/**
* Gets the current expert.
*
* @return the current expert
*/
public Expert getCurrentExpert() {
return currentExpert;
}
/**
* Sets the current expert.
*
* @param name the new current expert
*/
public void setCurrentExpert(ProblemElement pe) {
currentExpert = (Expert) pe;
}
}