public code v1
This commit is contained in:
+106
@@ -0,0 +1,106 @@
|
||||
package flintstones.valuation.linguistic.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
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.linguistic.LinguisticValuation;
|
||||
import flintstones.valuation.linguistic.ui.messages.Messages;
|
||||
import flintstones.valuation.ui.ValuationPanel;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class ValuationPanelLinguistic extends ValuationPanel {
|
||||
|
||||
private Combo labelCombo;
|
||||
|
||||
private LabelLinguisticDomain label;
|
||||
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
@Override
|
||||
protected void createControls() {
|
||||
UiService.setGridLayout(this.valuationPart, 1);
|
||||
|
||||
createBlock1Title();
|
||||
createBlock2LabelsCombo();
|
||||
}
|
||||
|
||||
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.Linguistic_evaluation);
|
||||
titleLabel.setBackground(new Color(Display.getCurrent(), 255, 255, 255));
|
||||
}
|
||||
|
||||
private void createBlock2LabelsCombo() {
|
||||
ArrayList<String> labelsName = ((FuzzySet) this.domain).getLabelSet().getLabelsName();
|
||||
this.labelCombo = new Combo(this.valuationPart, SWT.BORDER | SWT.READ_ONLY);
|
||||
GridData gd = UiService.setGridData(this.labelCombo, 0, 1, false, false);
|
||||
gd.verticalIndent = 10;
|
||||
this.labelCombo.setItems(labelsName.toArray(new String[0]));
|
||||
this.labelCombo.setBackground(new Color(Display.getCurrent(), 255, 255, 255));
|
||||
selectComboLabel();
|
||||
this.labelCombo.addModifyListener(e -> {
|
||||
ValuationPanelLinguistic.this.label =
|
||||
((FuzzySet) ValuationPanelLinguistic.this.domain)
|
||||
.getLabelSet()
|
||||
.getLabel(ValuationPanelLinguistic.this.labelCombo.getText());
|
||||
ValuationPanelLinguistic.this.selectionChange();
|
||||
});
|
||||
}
|
||||
|
||||
private void selectComboLabel() {
|
||||
int pos = 0;
|
||||
if (this.valuation != null && this.valuation instanceof LinguisticValuation) {
|
||||
this.label = ((LinguisticValuation) this.valuation).getLabel();
|
||||
pos = ((FuzzySet) this.domain).getLabelSet().getPos(this.label);
|
||||
} else
|
||||
this.label = ((FuzzySet) this.domain).getLabelSet().getLabel(pos);
|
||||
|
||||
this.labelCombo.select(pos);
|
||||
this.selectionChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSelection() {
|
||||
return this.labelCombo.getSelectionIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Valuation createNewValuation() {
|
||||
|
||||
LinguisticValuation result = null;
|
||||
|
||||
if (this.valuation == null) {
|
||||
result = (LinguisticValuation) this.valuationService.create(this.domain);
|
||||
result.setDomain(this.domain);
|
||||
} else
|
||||
result = (LinguisticValuation) this.valuation.clone();
|
||||
|
||||
result.setLabel(this.label);
|
||||
result.setEvaluated(true);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.valuation.linguistic.ui.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
|
||||
public String Linguistic_evaluation;
|
||||
public String Value;
|
||||
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Linguistic_evaluation=Linguistic evaluation
|
||||
Value=Value
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Linguistic_evaluation=Evaluación Linguistica
|
||||
Value=Valor
|
||||
Reference in New Issue
Block a user