|
|
|
@@ -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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|