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 @@
<?flintstones.helper.data.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,17 @@
<?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.valuation.hesitant.ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Ui</name>
<organization>
<name>Sinbad2</name>
</organization>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.valuation.hesitant.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>1779484362746</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,3 @@
eclipse.preferences.version=1
encoding//src/flintstones/valuation/hesitant/ui/messages/messages_zh_cn.properties=UTF-8
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,21 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: flintstones.valuation.hesitant.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Sinbad2
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: flintstones.valuation.hesitant.ui
Require-Bundle: flintstones.valuation.ui,
flintstones.valuation.hesitant,
flintstones.domain.fuzzyset,
org.eclipse.wb.swt,
javax.inject,
org.eclipse.e4.core.services,
org.eclipse.swt,
flintstones.operator,
flintstones.helper.data,
flintstones.entity.domain,
flintstones.model.valuation.service,
flintstones.entity.valuation,
flintstones.model.ui.service
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<?eclipse version="3.4"?>
<plugin>
<extension
point="flintstones.valuation.ui.extensionpoint">
<valuation_ui
uid="flintstones.valuation.hesitant.ui"
valuation="flintstones.valuation.hesitant"
valuation_panel="flintstones.valuation.hesitant.ui.ValuationPanelHesitant">
</valuation_ui>
</extension>
</plugin>
@@ -0,0 +1,508 @@
package flintstones.valuation.hesitant.ui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import javax.inject.Inject;
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.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.wb.swt.SWTResourceManager;
import flintstones.domain.fuzzyset.FuzzySet;
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
import flintstones.entity.valuation.Valuation;
import flintstones.model.ui.service.UiService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.valuation.hesitant.EUnaryRelationType;
import flintstones.valuation.hesitant.HesitantValuation;
import flintstones.valuation.hesitant.ui.messages.Messages;
import flintstones.valuation.ui.ValuationPanel;
@SuppressWarnings("javadoc")
public class ValuationPanelHesitant extends ValuationPanel {
@Inject
IValuationService valuationService;
@Inject
@Translation
private Messages messages;
private Button primaryButton;
private Button compositeButton;
private Button unaryRelationshipButton;
private Button binaryRelationshipButton;
private EUnaryRelationType unaryRelation;
private Combo primaryRelationCombo;
private Combo unaryRelationExpressionCombo;
private Combo unaryRelationLabelsCombo;
private Combo binaryLeftRelationCombo;
private Combo binaryRightRelationCombo;
private Label betweenLabel;
private Label andLabel;
private Composite evaluationsComposite;
private LabelLinguisticDomain term;
private LabelLinguisticDomain label;
private LabelLinguisticDomain upperTerm;
private LabelLinguisticDomain lowerTerm;
private List<Integer> selectIndexes = new LinkedList<>();
@Override
protected void createControls() {
UiService.setGridLayout(this.valuationPart, 1);
createBlock1Title();
Composite buttonsComposite = new Composite(this.valuationPart, SWT.NONE);
UiService.setGridLayout(buttonsComposite, 1, false);
GridData gd = UiService.setGridData(buttonsComposite, 9, 9, false, false);
gd.widthHint = 300;
createBlock2RelationButtons(buttonsComposite);
createBlock3RelationCompositeButtons(buttonsComposite);
createBlock4EvaluationComposite();
loadCreatedValuation();
}
private void createBlock1Title() {
Label titleLabel = new Label(this.valuationPart, SWT.NONE);
titleLabel.setFont(SWTResourceManager.getFont("Cantarell", 11, SWT.BOLD)); //$NON-NLS-1$
GridData gd = UiService.setGridData(titleLabel, 0, 0, true, false);
gd.verticalIndent = 15;
titleLabel.setText(this.messages.Hesitant_evaluation);
titleLabel.setBackground(new Color(Display.getCurrent(), 255, 255, 255));
}
private void createBlock2RelationButtons(Composite buttonsComposite) {
Group group1 = new Group(buttonsComposite, SWT.SHADOW_IN);
group1.setText("Select relation");
UiService.setGridLayout(group1, 2);
UiService.setGridData(group1, 0, 0, true, false);
this.primaryButton = new Button(group1, SWT.RADIO);
this.primaryButton.setText(this.messages.Primary);
GridData gd = UiService.setGridData(this.primaryButton, 9, 9, false, false);
gd.verticalIndent = 10;
this.primaryButton.addSelectionListener(primaryButtonSelectionListener());
this.compositeButton = new Button(group1, SWT.RADIO);
this.compositeButton.setText(this.messages.Composite);
gd = UiService.setGridData(this.compositeButton, 9, 9, false, false);
gd.verticalIndent = 10;
this.compositeButton.addSelectionListener(compositeButtonSelectionListener());
}
private SelectionAdapter primaryButtonSelectionListener() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
initializePrimaryButton();
notifyPrimarySelection();//Notify first selection
}
};
}
private void initializePrimaryButton() {
initializeEvaluationsComposite();
disabledUnaryRelation();
disabledBinaryRelation();
ValuationPanelHesitant.this.unaryRelationshipButton.setEnabled(false);
ValuationPanelHesitant.this.binaryRelationshipButton.setEnabled(false);
createPrimaryRelationCombo();
setPrimaryComboLabels();
addListenerPrimaryCombo();
}
private void createPrimaryRelationCombo() {
UiService.setGridLayout(evaluationsComposite, 1);
primaryRelationCombo = new Combo(evaluationsComposite, SWT.NONE);
UiService.setGridData(primaryRelationCombo, 9, 9, true, true);
evaluationsComposite.layout();
}
private void setPrimaryComboLabels() {
ArrayList<String> labelsName = ((FuzzySet) domain).getLabelSet().getLabelsName();
primaryRelationCombo.setItems(labelsName.toArray(new String[0]));
primaryRelationCombo.select(0);
}
private void addListenerPrimaryCombo() {
primaryRelationCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
notifyPrimarySelection();
}
});
}
private void notifyPrimarySelection() {
label = ((FuzzySet) domain).getLabelSet().getLabel(primaryRelationCombo.getText());
ValuationPanelHesitant.this.selectionChange();
}
private void disabledUnaryRelation() {
unaryRelation = null;
term = null;
}
private void disabledBinaryRelation() {
lowerTerm = null;
upperTerm = null;
}
private void initializeEvaluationsComposite() {
for(Control child: evaluationsComposite.getChildren())
child.dispose();
evaluationsComposite.layout();
}
private SelectionAdapter compositeButtonSelectionListener() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
initializeEvaluationsComposite();
ValuationPanelHesitant.this.unaryRelationshipButton.setEnabled(true);
ValuationPanelHesitant.this.binaryRelationshipButton.setEnabled(true);
if(unaryRelationshipButton.getSelection())
initializeUnaryRelation();
else if(binaryRelationshipButton.getSelection())
initializeBinaryRelation();
}
};
}
private void createBlock3RelationCompositeButtons(Composite buttonsComposite) {
Group group2 = new Group(buttonsComposite, SWT.NONE);
UiService.setGridLayout(group2, 2);
UiService.setGridData(group2, 0, 0, true, false);
this.unaryRelationshipButton = new Button(group2, SWT.RADIO);
this.unaryRelationshipButton.setText(this.messages.Unary);
UiService.setGridData(this.unaryRelationshipButton, 9, 9, false, false);
this.unaryRelationshipButton.addSelectionListener(unaryRelationButtonListener());
this.unaryRelationshipButton.setEnabled(false);
this.binaryRelationshipButton = new Button(group2, SWT.RADIO);
this.binaryRelationshipButton.setText(this.messages.Binary);
UiService.setGridData(this.binaryRelationshipButton, 9, 9, false, false);
this.binaryRelationshipButton.addSelectionListener(binaryRelationButtonListener());
this.binaryRelationshipButton.setEnabled(false);
}
private SelectionAdapter unaryRelationButtonListener() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
initializeUnaryRelation();
setInfoUnaryRelationCombos();
notifyUnarySelection();
}
};
}
private void initializeUnaryRelation() {
initializeEvaluationsComposite();
disabledPrimaryRelation();
disabledBinaryRelation();
createUnaryRelationCombos();
}
private void setInfoUnaryRelationCombos() {
setUnaryExpressionsCombo();
setUnaryLabelsCombo();
}
private void createUnaryRelationCombos() {
UiService.setGridLayout(evaluationsComposite, 2);
unaryRelationExpressionCombo = new Combo(evaluationsComposite, SWT.NONE);
UiService.setGridData(unaryRelationExpressionCombo, 9, 9, true, false);
unaryRelationExpressionCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
notifyUnarySelection();
setUnaryLabelsCombo();
}
});
unaryRelationLabelsCombo = new Combo(evaluationsComposite, SWT.NONE);
UiService.setGridData(unaryRelationLabelsCombo, 9, 9, true, false);
unaryRelationLabelsCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
notifyUnarySelection();
}
});
evaluationsComposite.layout();
}
private void setUnaryExpressionsCombo() {
String[] unaryTypes = new String[EUnaryRelationType.values().length];
for (int i = 0; i < EUnaryRelationType.values().length; ++i)
unaryTypes[i] = EUnaryRelationType.values()[i].toString();
unaryRelationExpressionCombo.setItems(unaryTypes);
if(unaryRelation == null)
unaryRelationExpressionCombo.select(0);
else
unaryRelationExpressionCombo.select(unaryRelationExpressionCombo.indexOf(unaryRelation.toString()));
}
private void setUnaryLabelsCombo() {
ArrayList<String> labelsName = ((FuzzySet) domain).getLabelSet().getLabelsName();
String[] arrayLabelsName = labelsName.toArray(new String[0]);
if(unaryRelationExpressionCombo.getText().equals(EUnaryRelationType.LowerThan.toString()))
unaryRelationLabelsCombo.setItems(Arrays.copyOfRange(
arrayLabelsName, 1, arrayLabelsName.length));
else if(unaryRelationExpressionCombo.getText().equals(EUnaryRelationType.GreaterThan.toString()))
unaryRelationLabelsCombo.setItems(Arrays.copyOfRange(
arrayLabelsName, 0, arrayLabelsName.length - 1));
else
unaryRelationLabelsCombo.setItems(arrayLabelsName);
if(unaryRelation == null)
unaryRelationLabelsCombo.select(0);
else
unaryRelationLabelsCombo.setText(term.getName());
}
private void notifyUnarySelection() {
String unaryType = unaryRelationExpressionCombo.getText();
unaryRelation = EUnaryRelationType.getEUnaryRelationType(unaryType);
unaryRelation.setRelationType(unaryType);
term = ((FuzzySet) domain).getLabelSet().getLabel(unaryRelationLabelsCombo.getText());
ValuationPanelHesitant.this.selectionChange();
}
private void disabledPrimaryRelation() {
label = null;
}
private SelectionAdapter binaryRelationButtonListener() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
initializeBinaryRelation();
setInfoBinaryRelationCombos();
notifyBinarySelection();
}
};
}
private void initializeBinaryRelation() {
initializeEvaluationsComposite();
disabledPrimaryRelation();
disabledUnaryRelation();
createBinaryRelationCombosAndLabels();
}
private void createBinaryRelationCombosAndLabels() {
UiService.setGridLayout(evaluationsComposite, 4);
betweenLabel = new Label(evaluationsComposite, SWT.NONE);
betweenLabel.setText(messages.Between);
UiService.setGridData(betweenLabel, 9, 9, true, false);
binaryLeftRelationCombo = new Combo(evaluationsComposite, SWT.NONE);
UiService.setGridData(binaryLeftRelationCombo, 9, 9, true, false);
binaryLeftRelationCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
notifyBinarySelection();
setInfoCombosRegardingLeftCombo();
}
});
andLabel = new Label(evaluationsComposite, SWT.NONE);
andLabel.setText(messages.And);
UiService.setGridData(andLabel, 9, 9, true, false);
binaryRightRelationCombo = new Combo(evaluationsComposite, SWT.NONE);
UiService.setGridData(binaryRightRelationCombo, 9, 9, true, false);
binaryRightRelationCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
notifyBinarySelection();
setInfoCombosRegardingRightCombo();
}
});
evaluationsComposite.layout();
}
private void setInfoBinaryRelationCombos() {
setInfoCombosRegardingLeftCombo();
setInfoCombosRegardingRightCombo();
}
private void setInfoCombosRegardingLeftCombo() {
ArrayList<String> labelsName = ((FuzzySet) domain).getLabelSet().getLabelsName();
String[] arrayLabelsName = labelsName.toArray(new String[0]);
if(lowerTerm == null && upperTerm == null) {//Default case
binaryLeftRelationCombo.setItems(Arrays.copyOfRange(arrayLabelsName, 0, 1));//First label
binaryLeftRelationCombo.select(0);
} else {
int posLowerTerm = ((FuzzySet) domain).getLabelSet().getPos(lowerTerm);
binaryRightRelationCombo.setItems(Arrays.copyOfRange(arrayLabelsName, posLowerTerm + 1, arrayLabelsName.length));//First label
binaryRightRelationCombo.setText(upperTerm.getName());
}
}
private void setInfoCombosRegardingRightCombo() {
ArrayList<String> labelsName = ((FuzzySet) domain).getLabelSet().getLabelsName();
String[] arrayLabelsName = labelsName.toArray(new String[0]);
if(lowerTerm == null && upperTerm == null) {//Default case
binaryRightRelationCombo.setItems(Arrays.copyOfRange(arrayLabelsName, 1, arrayLabelsName.length));//All labels except first one
binaryRightRelationCombo.select(0);
} else {
int posUpperTerm = ((FuzzySet) domain).getLabelSet().getPos(upperTerm);
binaryLeftRelationCombo.setItems(Arrays.copyOfRange(arrayLabelsName, 0, posUpperTerm));
binaryLeftRelationCombo.setText(lowerTerm.getName());
}
}
private void notifyBinarySelection() {
lowerTerm = ((FuzzySet) domain).getLabelSet().getLabel(binaryLeftRelationCombo.getText());
upperTerm = ((FuzzySet) domain).getLabelSet().getLabel(binaryRightRelationCombo.getText());
ValuationPanelHesitant.this.selectionChange();
}
private void createBlock4EvaluationComposite() {
evaluationsComposite = new Composite(this.valuationPart, SWT.NONE);
UiService.setGridLayout(evaluationsComposite, 1);
UiService.setGridData(evaluationsComposite, 9, 9, false, true);
}
@Override
public Object getSelection() {
return selectIndexes;
}
@Override
public Valuation createNewValuation() {
selectIndexes.clear();
HesitantValuation result = null;
if (this.valuation == null) {
result = (HesitantValuation) this.valuationService.create(this.domain);
result.setDomain(this.domain);
} else {
result = (HesitantValuation) this.valuation.clone();
}
if(isPrimary()) {
result.setLabel(this.label);
this.selectIndexes.add(primaryRelationCombo.getSelectionIndex());
} else {
if(isUnary())
result.setUnaryRelation(unaryRelation, term);
else if (isBinary())
result.setBinaryRelation(binaryLeftRelationCombo.getText(),
binaryRightRelationCombo.getText());
else {
try {
throw new Exception("Not valid relation");
} catch (Exception e) {
e.printStackTrace();
}
}
int[] envelope = result.getEnvelopeIndex();
selectIndexes.add(envelope[0]);
selectIndexes.add(envelope[1]);
}
result.setEvaluated(true);
return result;
}
public boolean isPrimary() {
return (this.label != null);
}
public boolean isUnary() {
return ((this.unaryRelation != null) && (this.term != null));
}
public boolean isBinary() {
return ((this.lowerTerm != null) && (this.upperTerm != null));
}
private void loadCreatedValuation() {
if(valuation != null) {
if(((HesitantValuation) valuation).isPrimary()) {
initializePrimaryButton();
primaryButton.setSelection(true);
label = ((HesitantValuation) valuation).getLabel();
unaryRelationshipButton.setEnabled(false);
binaryRelationshipButton.setEnabled(false);
primaryRelationCombo.select(((FuzzySet) domain).getLabelSet().getPos(label));
} else if(((HesitantValuation) valuation).isUnary()) {
initializeUnaryRelation();
unaryRelationshipButton.setEnabled(true);
binaryRelationshipButton.setEnabled(true);
compositeButton.setSelection(true);
unaryRelationshipButton.setSelection(true);
unaryRelation = ((HesitantValuation) valuation).getUnaryRelation();
term = ((HesitantValuation) valuation).getTerm();
setInfoUnaryRelationCombos();
} else {
initializeBinaryRelation();
compositeButton.setSelection(true);
binaryRelationshipButton.setSelection(true);
unaryRelationshipButton.setEnabled(true);
binaryRelationshipButton.setEnabled(true);
lowerTerm = ((HesitantValuation) valuation).getLowerTerm();
upperTerm = ((HesitantValuation) valuation).getUpperTerm();
setInfoBinaryRelationCombos();
}
ValuationPanelHesitant.this.selectionChange();
}
}
}
@@ -0,0 +1,18 @@
// This file has been auto-generated
package flintstones.valuation.hesitant.ui.messages;
import org.eclipse.e4.core.services.nls.Message;
@Message
@SuppressWarnings("javadoc")
public class Messages {
public String Hesitant_evaluation;
public String Primary;
public String Composite;
public String Unary;
public String Binary;
public String Between;
public String And;
}
@@ -0,0 +1,7 @@
And=and
Between=Between
Binary=Binary
Composite=Composite
Hesitant_evaluation=Hesitant evaluation
Primary=Primary
Unary=Unary
@@ -0,0 +1,7 @@
And=y
Between=entre
Binary=Binario
Composite=Compuesto
Hesitant_evaluation=Valoración hesitant
Primary=Primaria
Unary=Unaria
@@ -0,0 +1,7 @@
And=
Between=之间
Binary=二元型
Composite=混合型
Hesitant_evaluation=犹豫值评估
Primary=初始值
Unary=一元型