public code v1
This commit is contained in:
@@ -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>
|
||||
+14
@@ -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.common.phase.collectweights.criterion.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.common.phase.collectweights.criterion.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>1779484362645</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>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
+7
@@ -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
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ui
|
||||
Bundle-SymbolicName: flintstones.method.common.phase.collectweights.criterion.ui;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.common.phase.collectweights.criterion.ui
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.entity.method.phase.ui,
|
||||
flintstones.model.method.phase.service,
|
||||
flintstones.model.problemelement.service,
|
||||
javax.inject,
|
||||
org.eclipse.swt,
|
||||
flintstones.helper.ui,
|
||||
flintstones.entity.problemelement.ui,
|
||||
flintstones.entity.problemelement,
|
||||
flintstones.helper.data,
|
||||
flintstones.model.ui.service,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.method.common.phase.collectweights.criterion,
|
||||
flintstones.helper.debug,
|
||||
org.eclipse.e4.core.services
|
||||
@@ -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.common.phase.collectweights.criterion.ui"
|
||||
implementation="flintstones.method.common.phase.collectweights.criterion.ui.CollectWeightsCriterionUI"
|
||||
phasemethod="flintstones.method.common.phase.collectweights.criterion">
|
||||
</phasemethod_ui>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
package flintstones.method.common.phase.collectweights.criterion.ui;
|
||||
|
||||
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.common.phase.collectweights.criterion.CollectWeightsCriterionModel;
|
||||
import flintstones.method.common.phase.collectweights.criterion.ui.messages.Messages;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
public class CollectWeightsCriterionUI extends PhaseMethodUI
|
||||
implements IProblemElementChangedListener, WItemChanged, WItemBeforeOperation, WItemOperation {
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
Messages messages;
|
||||
|
||||
CollectWeightsCriterionModel model;
|
||||
|
||||
Composite phaseBase;
|
||||
|
||||
// Components
|
||||
ProblemElementSelector selector;
|
||||
WCollector collector;
|
||||
Label adviceLabel;
|
||||
|
||||
ProblemElement currentItem;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
model = (CollectWeightsCriterionModel) this.getModel();
|
||||
Composite base = this.getBaseComposite();
|
||||
|
||||
|
||||
createControls(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isForwardEnabled() {
|
||||
return model.isFilled();
|
||||
}
|
||||
|
||||
private void createControls(Composite base) {
|
||||
|
||||
ProblemElement[] items = model.getExperts();
|
||||
ProblemElement[] subItems = model.getCriteria();
|
||||
currentItem = items[0];
|
||||
|
||||
UiService.setGridLayout(base, 1);
|
||||
UiService.setGridDataAuto(base);
|
||||
|
||||
Composite row = new Composite(base, 0);
|
||||
UiService.setGridLayout(row, 3, false);
|
||||
UiService.setGridData(row, 9, -1, true, false);
|
||||
|
||||
selector = new ProblemElementSelector(row, items);
|
||||
selector.setListener(this);
|
||||
selector.setText(Expert.Type);
|
||||
|
||||
adviceLabel = new Label(row, 0);
|
||||
adviceLabel.setText(messages.Condition); //$NON-NLS-1$
|
||||
|
||||
Composite row2 = new Composite(base, 0);
|
||||
UiService.setGridLayout(row2, 1, true);
|
||||
UiService.setGridDataAuto(row2);
|
||||
|
||||
collector = new WCollector(row2);
|
||||
collector.setHeaders(Arrays.stream(subItems).map(k -> k.getName()).toArray(String[]::new));
|
||||
collector.setChangeListener(this);
|
||||
collector.setBeforeOperationListener(this);
|
||||
collector.setOperationListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBeExecuted(WEvent operationType, String before, String after) {
|
||||
|
||||
ProblemElement[] subItems = model.getCriteria();
|
||||
|
||||
if (operationType.equals(WEvent.ADD)) {
|
||||
|
||||
String[] data = collector.getData();
|
||||
|
||||
// Same lenth, limit reached
|
||||
if(data.length == subItems.length)
|
||||
return false;
|
||||
|
||||
// Lets sum
|
||||
double sum = 0.0;
|
||||
for(String value : data) {
|
||||
sum += Double.parseDouble(value);
|
||||
}
|
||||
sum += DoubleHelper.NormalizeZeroToOne(before);
|
||||
|
||||
// When the last element in introduced must sum 1
|
||||
if(data.length == subItems.length-1) {
|
||||
return DoubleHelper.Equals(sum, 1.0, 5);
|
||||
} else { // Must not sum over 1 in any case
|
||||
return sum <= 1.0;
|
||||
}
|
||||
|
||||
} else if (operationType.equals(WEvent.CLEAR)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWidgetChange() {
|
||||
ProblemElement[] subItems = model.getCriteria();
|
||||
|
||||
String[] data = collector.getData();
|
||||
for (int i = 0; i < subItems.length && i < data.length; i++) {
|
||||
model.addWeight(currentItem, subItems[i], DoubleHelper.ParseDouble(data[i]));
|
||||
}
|
||||
|
||||
sendRefresh();
|
||||
|
||||
boolean status = data.length == subItems.length;
|
||||
selector.setStatus(currentItem, status);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void problemElementChanged(ProblemElement pe) {
|
||||
|
||||
ProblemElement[] subItems = model.getCriteria();
|
||||
|
||||
currentItem = pe;
|
||||
|
||||
ArrayList<String> data = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < subItems.length; i++) {
|
||||
Double value = model.getWeight(currentItem, subItems[i]);
|
||||
if (value != null)
|
||||
data.add(value + ""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
collector.setValues(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModifiedValue(WEvent operationType, String before, String after) {
|
||||
if (operationType.equals(WEvent.ADD)) {
|
||||
return DoubleHelper.NormalizeZeroToOne(before)+""; //$NON-NLS-1$
|
||||
}
|
||||
return after;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package flintstones.method.common.phase.collectweights.criterion.ui.messages;
|
||||
|
||||
public class Messages {
|
||||
public String Condition;
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Condition=The values must add up to one. It is possible to introduce positive integers as shortcut.
|
||||
+1
@@ -0,0 +1 @@
|
||||
Condition=Los valores deben sumar exactamente 1. Es posible introducir números enteros como atajo.
|
||||
Reference in New Issue
Block a user