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.decision.common.phase.collectweights.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.collectweights.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>1779484362658</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,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: flintstones.method.decision.common.phase.collectweights.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.method.decision.common.phase.collectweights.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: flintstones.method.decision.common.phase.collectweights,
org.eclipse.swt,
flintstones.helper.ui,
javax.inject,
flintstones.helper.wtable,
flintstones.entity.problemelement,
flintstones.entity.ahp.decisionmatrix,
flintstones.model.problemelement.service,
flintstones.entity.domain,
flintstones.entity.domain.ui.chart,
flintstones.model.domain.ui.service,
flintstones.model.ui.service,
flintstones.entity.method.phase,
flintstones.entity.method.phase.ui
Export-Package: flintstones.method.decision.common.phase.collectweights.ui.provider
@@ -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.decision.common.phase.collectweights.ui"
implementation="flintstones.method.decision.common.phase.collectweights.ui.CollectWeightsUI"
phasemethod="flintstones.method.decision.common.phase.collectweights">
</phasemethod_ui>
</extension>
</plugin>
@@ -0,0 +1,140 @@
package flintstones.method.decision.common.phase.collectweights.ui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import javax.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import flintstones.entity.domain.ui.chart.DomainChart;
import flintstones.entity.method.phase.ui.PhaseMethodUI;
import flintstones.entity.problemelement.entities.Criterion;
import flintstones.entity.problemelement.entities.Expert;
import flintstones.entity.problemelement.entities.ProblemElement;
import flintstones.helper.wtable.WTable;
import flintstones.helper.wtable.WTableModel;
import flintstones.helper.wtable.event.WTableCellModifiedListener;
import flintstones.method.decision.common.phase.collectweights.CollectWeightsModel;
import flintstones.method.decision.common.phase.collectweights.ui.provider.WeightCollectionTableCell;
import flintstones.model.domain.ui.service.IDomainUIService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.ui.service.UiService;
public class CollectWeightsUI extends PhaseMethodUI implements WTableCellModifiedListener {
@Inject
IProblemElementService problemService;
@Inject
IDomainUIService uiDomainService;
CollectWeightsModel model;
ArrayList<ArrayList<WeightCollectionTableCell>> cells;
WTableModel wtableModel;
WTable table;
@Override
public void init() {
model = (CollectWeightsModel) this.getModel();
createPartControls(this.getBaseComposite());
compute();
}
@Override
public void refresh() {
}
@Override
public boolean isForwardEnabled() {
return true;
}
private void createPartControls(Composite parent) {
UiService.setGridData(parent, 9, 9, true, true);
UiService.setGridLayout(parent, 1);
createTable(parent);
createChart(parent);
}
private void createChart(Composite parent) {
Composite base = new Composite(parent, SWT.BORDER);
UiService.setGridData(base, 9, 9, true, true);
UiService.setGridLayout(base, 1);
base.setBackground(UiService.getColor(0, 0, 100));
base.setLayout(new FillLayout());
DomainChart chart = uiDomainService.createChart( model.getDomain().getType() );
chart.initialize(model.getDomain(), base, 500, 500, SWT.BORDER);
base.layout(true);
}
private void createTable(Composite parent) {
Composite base = new Composite(parent, SWT.BORDER);
UiService.setGridData(base, 9, 9, true, true);
UiService.setGridLayout(base, 1);
base.setLayout(new FillLayout());
table = new WTable(base, 0);
table.setLayout(new FillLayout());
wtableModel = new WTableModel(table);
ArrayList<ProblemElement> experts = new ArrayList<ProblemElement>(Arrays.asList(problemService.getSubElements(Expert.Type)));
ArrayList<ProblemElement> criterions = new ArrayList<ProblemElement>(Arrays.asList(problemService.getSubElements(Criterion.Type)));
cells = new ArrayList<>();
for (ProblemElement c : criterions) {
ArrayList<WeightCollectionTableCell> row = new ArrayList<>();
for (ProblemElement e : experts) {
row.add(new WeightCollectionTableCell((Expert) e, (Criterion) c, 0.5));
}
cells.add(row);
}
wtableModel.setHorizontalHeaders(criterions.stream()
.map(k -> k.getName())
.toArray(String[]::new));
wtableModel.setVerticalHeaders(experts.stream()
.map(k -> k.getName())
.toArray(String[]::new));
wtableModel.addContent(cells);
wtableModel.addListener(this);
table.setModel(wtableModel);
// table.setBackground(UiService.getColor(100, 0, 0));
wtableModel.init();
}
@Override
public void cellModified(int col, int row, Object oldValue, Object newValue) {
compute();
}
private void compute() {
HashMap<Criterion, Double> criterionWeights = new HashMap<>();
for(ArrayList<WeightCollectionTableCell> column : cells ) {
double avg = column.stream().mapToDouble( k -> k.getWeight() ).average().getAsDouble();
criterionWeights.put(column.get(0).getCriterion(), avg);
}
model.export(criterionWeights);
}
}
@@ -0,0 +1,137 @@
package flintstones.method.decision.common.phase.collectweights.ui.provider;
import de.kupzog.ktable.KTableCellEditor;
import flintstones.entity.problemelement.entities.Criterion;
import flintstones.entity.problemelement.entities.Expert;
import flintstones.helper.wtable.cell.WTableCell;
import flintstones.helper.wtable.interfaces.IWTableCellContent;
import flintstones.helper.wtable.interfaces.IWTableCellEditor;
import flintstones.helper.wtable.interfaces.IWTableCellEventModified;
import flintstones.helper.wtable.wcelleditor.WCellEditorFloatingSpinner;
/**
* The Class WeightCollectionTableCell.
*/
public class WeightCollectionTableCell extends WTableCell implements IWTableCellContent, IWTableCellEditor, IWTableCellEventModified {
/** The weight. */
double weight = 0.0;
/** The editor. */
WCellEditorFloatingSpinner editor;
/** The e. */
Expert e;
/** The c. */
Criterion c;
/**
* Instantiates a new weight collection table cell.
*
* @param e the e
* @param c the c
* @param weight the weight
*/
public WeightCollectionTableCell(Expert e, Criterion c, double weight) {
this.e = e;
this.c = c;
this.weight = weight;
}
/* (non-Javadoc)
* @see flintstones.helper.wtable.interfaces.IWTableCellContent#getContent(java.lang.Object)
*/
@Override
public Object getContent(Object cellContent) {
return weight;
}
/* (non-Javadoc)
* @see flintstones.helper.wtable.interfaces.IWTableCellContent#shouldFireModifiedEvent()
*/
@Override
public boolean shouldFireModifiedEvent() {
return true;
}
/* (non-Javadoc)
* @see flintstones.helper.wtable.interfaces.IWTableCellContent#shouldSetContent()
*/
@Override
public boolean shouldSetContent() {
return false;
}
/* (non-Javadoc)
* @see flintstones.helper.wtable.interfaces.IWTableCellEditor#getCellEditor()
*/
@Override
public KTableCellEditor getCellEditor() {
if( editor == null ) {
editor = new WCellEditorFloatingSpinner();
editor.setDigits(2);
}
return editor;
}
/**
* Gets the weight.
*
* @return the weight
*/
public double getWeight() {
return weight;
}
/* (non-Javadoc)
* @see flintstones.helper.wtable.cell.WTableCell#toString()
*/
@Override
public String toString() {
return this.weight + "";
}
/* (non-Javadoc)
* @see flintstones.helper.wtable.interfaces.IWTableCellEventModified#cellModified(int, int, java.lang.Object, java.lang.Object)
*/
@Override
public void cellModified(int col, int row, Object oldContent, Object newContent) {
String newContentS = (String)newContent;
// Value must be between 0 and 1.
// Format should be X.YY.
// Fix 1, if format is X,YY
newContentS = newContentS.replace(",",".");
// Current double value
double value = Double.parseDouble(newContentS);
// Fix 2, if user input 1 we will write 0.1 as a shortcut.
// Also If the users imputs 55, we will write 0.55. Bigger integers will be ignored.
if( value > 1.00 ) // we allow 1.00
if( value < 10.0 )
value /= 10;
else if( value > 10.0 && value < 100.0 )
value /= 100;
else
value = weight;
this.weight = value;
}
/**
* Gets the criterion.
*
* @return the criterion
*/
public Criterion getCriterion() {
return c;
}
}