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-11"/>
<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.fuzzy.common.phase.collectweights.experts.ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Bundle-Name</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.method.fuzzy.common.phase.collectweights.experts.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>1779484362675</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,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,21 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: flintstones.method.fuzzy.common.phase.collectweights.experts.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.method.fuzzy.common.phase.collectweights.experts.ui
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: flintstones.entity.method.phase.ui,
org.eclipse.e4.core.services,
javax.inject,
flintstones.method.fuzzy.common.phase.collectweights.experts,
flintstones.model.valuation.service,
flintstones.helper.ui,
flintstones.entity.problemelement.ui,
flintstones.entity.method.phase,
flintstones.model.ui.service,
flintstones.entity.problemelement,
flintstones.domain.fuzzyset,
flintstones.valuation.linguistic,
flintstones.helper.data,
flintstones.helper.faq
@@ -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
implementation="flintstones.method.fuzzy.common.phase.collectweights.experts.ui.FuzzyCollectWeightsExpertsUI"
phasemethod="flintstones.method.fuzzy.common.phase.collectweights.experts"
uid="flintstones.method.fuzzy.common.phase.collectweights.experts.ui">
</phasemethod_ui>
</extension>
</plugin>
@@ -0,0 +1,311 @@
package flintstones.method.fuzzy.common.phase.collectweights.experts.ui;
import org.eclipse.e4.core.services.nls.Translation;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import flintstones.domain.fuzzyset.function.types.TrapezoidalFunction;
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
import flintstones.entity.method.phase.ui.PhaseMethodUI;
import flintstones.entity.problemelement.entities.Expert;
import flintstones.entity.problemelement.entities.ProblemElement;
import flintstones.entity.problemelement.ui.widget.ProblemElementSelector;
import flintstones.entity.problemelement.ui.widget.listener.IProblemElementChangedListener;
import flintstones.helper.DoubleHelper;
import flintstones.helper.ui.components.WCollector;
import flintstones.helper.ui.components.listeners.WEvent;
import flintstones.helper.ui.components.listeners.WItemBeforeOperation;
import flintstones.helper.ui.components.listeners.WItemChanged;
import flintstones.helper.ui.components.listeners.WItemOperation;
import flintstones.method.fuzzy.common.phase.collectweights.experts.FuzzyCollectWeightsExperts;
import flintstones.method.fuzzy.common.phase.collectweights.experts.ui.messages.Messages;
import flintstones.model.ui.service.UiService;
import flintstones.model.valuation.service.IValuationService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
public class FuzzyCollectWeightsExpertsUI extends PhaseMethodUI
implements WItemBeforeOperation, WItemChanged, IProblemElementChangedListener {
@Inject
IValuationService valuationService;
// Model implementation
FuzzyCollectWeightsExperts model;
// Weights collector table
WCollector collector;
// Select expert
ProblemElementSelector selector;
// Select linguistic domain
Combo domainSelector;
// Select linguistic label
Combo labelSelector;
// Messages class containing localised strings
@Inject
@Translation
Messages msg;
/**
* Init interface
*/
@Override
public void init() {
model = (FuzzyCollectWeightsExperts) this.getModel();
Composite base = this.getBaseComposite();
UiService.setGridDataAuto(base);
UiService.setGridLayout(base, 1);
//<--- TOP COMPOSITE --->
Composite topRow = new Composite(base, SWT.BORDER);
UiService.setGridData(topRow, 0, -1, true, false);
UiService.setGridLayout(topRow, 1, false);
//Expert selector
Composite expComp = new Composite(topRow, SWT.NONE);
UiService.setGridData(expComp, 0, 0, false, false);
UiService.setGridLayout(expComp, 2, false);
selector = new ProblemElementSelector(expComp, model.getExperts());
selector.setText(Expert.Type);
selector.setListener(this);
String[] linguisticDomainsNames = model.getLinguisticDomainsName();
if(linguisticDomainsNames.length != 0) //Linguistic label for weight selector
createLinguisticDomainSelector(topRow, linguisticDomainsNames);
//<--- CENTRAL COMPOSITE --->
Composite midRow = new Composite(base, SWT.NONE);
UiService.setGridLayout(midRow, 1, true);
UiService.setGridData(midRow, 9, 9, true, true);
// Data collector
String[] fuzzy = new String[] { "l", "m", "r" };
collector = new WCollector(midRow);
collector.setHeaders(fuzzy);
collector.setBeforeOperationListener(this);// shouldBeExecuted
collector.setChangeListener(this);// onWidgetChange
collector.setOperationListener(new WItemOperation() {
/**
* Allows input of integer numbers as decimals.
*/
@Override
public String getModifiedValue(WEvent operationType, String before, String after) {
return Double.toString(DoubleHelper.NormalizeZeroToOne(before));
}
});
}
private void createLinguisticDomainSelector(Composite topRow, String[] linguisticDomainsNames) {
Composite tagComp = new Composite(topRow, SWT.NONE);
UiService.setGridLayout(tagComp, 3, false);
UiService.setGridData(tagComp, 0, 0, false, false);
createComboDomain(tagComp, linguisticDomainsNames);
createComboLabel(tagComp);
createAddLabelButton(tagComp);
}
private void createAddLabelButton(Composite tagComp) {
// Add tag button
Button tagAdd = new Button(tagComp, SWT.NONE);
tagAdd.setText(msg.buttonTag);
tagAdd.addSelectionListener(new SelectionAdapter() {
/**
* Assigns the selected label value to next weight
*/
@Override
public void widgetSelected(SelectionEvent e) {
List<LabelLinguisticDomain> labels = model.getLabelsFromDomainName(domainSelector.getText());
String[] newData = new String[3];
TrapezoidalFunction selected = (TrapezoidalFunction) labels.get(labelSelector.getSelectionIndex()).getSemantic();
newData[0] = Double.toString(selected.getA());
newData[1] = Double.toString(selected.getB());
newData[2] = Double.toString(selected.getD());
collector.setValues(new ArrayList<String>(Arrays.asList(newData)));
selector.setStatus(selector.getSelectedElement(), true);
saveWeigths(newData);
}
});
}
private void createComboDomain(Composite tagComp, String[] linguisticDomainsNames) {
Composite linguisticDomainSelectionComposite = new Composite(tagComp, SWT.NONE);
UiService.setGridLayout(linguisticDomainSelectionComposite, 2, false);
UiService.setGridData(linguisticDomainSelectionComposite, 0, 0, false, false);
Label label_domain = new Label(linguisticDomainSelectionComposite, SWT.NONE);
label_domain.setText(msg.selectLingDomain);
domainSelector = new Combo(linguisticDomainSelectionComposite, SWT.NONE);
for (String name : linguisticDomainsNames)
domainSelector.add(name);
domainSelector.select(0);
domainSelector.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setLabelsToLabelCombo();
}
});
}
private void createComboLabel(Composite tagComp) {
Composite labelSelectionComposite = new Composite(tagComp, SWT.NONE);
UiService.setGridLayout(labelSelectionComposite, 2, false);
UiService.setGridData(labelSelectionComposite, 0, 0, false, false);
Label label = new Label(labelSelectionComposite, SWT.NONE);
label.setText(msg.selectTag);
labelSelector = new Combo(labelSelectionComposite, SWT.NONE);
setLabelsToLabelCombo();
}
private void setLabelsToLabelCombo() {
labelSelector.removeAll();
List<LabelLinguisticDomain> labels = model.getLabelsFromDomainName(domainSelector.getText());
for (LabelLinguisticDomain lb : labels)
labelSelector.add(lb.getName());
labelSelector.select(0);
}
@Override
public void refresh() {
}
/**
* @return true if next phase is available, otherwise false
*/
@Override
protected boolean isForwardEnabled() {
return model.isFilled();
}
/**
* Listener to check the new weight
*
* @return true to add, otherwise false
*/
@Override
public boolean shouldBeExecuted(WEvent operationType, String before, String after) {
if (operationType.equals(WEvent.ADD)) {
String[] data = collector.getData();
if (data.length < 3) {// at most three values
if (data.length >= 1) {// check order when more than 1 value
for (String d : data) {
if(DoubleHelper.NormalizeZeroToOne(d) > DoubleHelper.NormalizeZeroToOne(before)) {
return false;
}
}
return true;
} else
return true;
} else
return false;
} else if (operationType.equals(WEvent.CLEAR)) {
return true;
}
return false;
}
/**
* Listener to add a new weight
*/
@Override
public void onWidgetChange() {
updateStatus();
}
/**
* Updates expert completion status
*/
private void updateStatus() {
String[] data = collector.getData();
Float sum = 0.0f;
for (int i = 0; i < data.length; i++) {
sum += Float.valueOf(data[i]);
}
// <--- WEIGHT SUM T --->
// ArrayList<String> newData = new ArrayList<>(Arrays.asList(data));
// //If sum exceeds 1, don't add the new weight
// if (sum > 1.0f) {
// newData.remove(newData.size() - 1);
// collector.setValues(newData);
// data = collector.getData();
// } else if (data.length == 2) { // Else, if only 1 remains, adds it directly
// newData.add(Float.toString(1.0f - sum));
// collector.setValues(newData);
// data = collector.getData();
// }
if (data.length == 3) {
saveWeigths(data);
selector.setStatus(selector.getSelectedElement(), true);
} else {
selector.setStatus(selector.getSelectedElement(), false);
}
}
/**
* Saves weigths for the next phase
*
* @param data Weigths to save
*/
private void saveWeigths(String[] data) {
double[] fuzzyNumber = new double[data.length];
for (int i = 0; i < data.length; i++)
fuzzyNumber[i] = DoubleHelper.ParseDouble(data[i]);
model.addWeight(selector.getSelectedElement(), new TrapezoidalFunction(fuzzyNumber));
sendRefresh();
}
/**
* Called when changing selected expert
*/
@Override
public void problemElementChanged(ProblemElement pe) {
ArrayList<String> dt = new ArrayList<>();
TrapezoidalFunction weight = model.getWeight(pe);
// If there is weight, add to the list
if (weight != null) {
for (Double v : weight.getLimits())
dt.add(v + "");
dt.remove(1);// Remove the second value since it is the same of the third value
}
collector.setValues(dt);
}
}
@@ -0,0 +1,10 @@
package flintstones.method.fuzzy.common.phase.collectweights.experts.ui.messages;
import org.eclipse.e4.core.services.nls.Message;
@Message
public class Messages {
public String selectLingDomain;
public String selectTag;
public String buttonTag;
}
@@ -0,0 +1,3 @@
selectLingDomain=Select domain
selectTag=Select label for weight
buttonTag=Add
@@ -0,0 +1,3 @@
selectLingDomain=Selecciona dominio
selectTag=Selecciona etiqueta para el peso
buttonTag=Añadir