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.bestworst.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.bestworst.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>1779484362643</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
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ui
|
||||
Bundle-SymbolicName: flintstones.method.common.phase.collectweights.bestworst.ui;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.common.phase.collectweights.bestworst.ui
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.entity.method.phase.ui,
|
||||
flintstones.method.common.phase.collectweights.bestworst,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.model.ui.service,
|
||||
org.eclipse.swt,
|
||||
flintstones.helper.ui,
|
||||
flintstones.entity.problemelement,
|
||||
org.eclipse.nebula.widgets.opal.commons,
|
||||
org.apache.commons.lang,
|
||||
flintstones.entity.problemelement.ui
|
||||
@@ -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.bestworst.ui"
|
||||
implementation="flintstones.method.common.phase.collectweights.bestworst.ui.BestWorstUI"
|
||||
phasemethod="flintstones.method.common.phase.collectweights.bestworst">
|
||||
</phasemethod_ui>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
package flintstones.method.common.phase.collectweights.bestworst.ui;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.nebula.widgets.opal.commons.SWTGraphicUtil;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
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.Label;
|
||||
|
||||
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.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.method.common.phase.collectweights.bestworst.BestWorstModel;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
public class BestWorstUI extends PhaseMethodUI implements IProblemElementChangedListener {
|
||||
|
||||
BestWorstModel model;
|
||||
|
||||
ProblemElement currentItem;
|
||||
|
||||
ProblemElementSelector selector;
|
||||
|
||||
Combo bestCombo;
|
||||
WCollector bestCollector;
|
||||
|
||||
Combo worstCombo;
|
||||
WCollector worstCollector;
|
||||
|
||||
Composite leftInner;
|
||||
Composite rightInner;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
model = (BestWorstModel) this.getModel();
|
||||
|
||||
Composite base = this.getBaseComposite();
|
||||
UiService.setGridLayout(base, 1);
|
||||
UiService.setGridDataAuto(base);
|
||||
|
||||
selector = new ProblemElementSelector(base, model.getExperts());
|
||||
selector.setListener(this);
|
||||
selector.setText(Expert.Type);
|
||||
currentItem = model.getExperts()[0];
|
||||
|
||||
Composite comparisons = new Composite(base, SWT.NONE);
|
||||
UiService.setGridLayout(comparisons, 2, true);
|
||||
UiService.setGridDataAuto(comparisons);
|
||||
|
||||
Composite left = new Composite(comparisons,0);
|
||||
UiService.setGridLayout(left, 1);
|
||||
UiService.setGridDataAuto(left);
|
||||
|
||||
Composite right = new Composite(comparisons,0);
|
||||
UiService.setGridLayout(right, 1);
|
||||
UiService.setGridDataAuto(right);
|
||||
|
||||
// Left
|
||||
Label bestLabel = new Label(left,0);
|
||||
bestLabel.setText("The BEST criterion is: ");
|
||||
UiService.setFont(bestLabel, UiService.FONT_SECTION_TITLE);
|
||||
|
||||
bestCombo = new Combo(left, SWT.READ_ONLY);
|
||||
GridData gd = UiService.setGridData(bestCombo, 9, -1, true, false);
|
||||
gd.verticalIndent = 10;
|
||||
|
||||
Label bestLabel2 = new Label(left,0);
|
||||
bestLabel2.setText("Best -> Others: (1-9) ");
|
||||
UiService.setFont(bestLabel2, UiService.FONT_SECTION_TITLE);
|
||||
gd = UiService.setGridData(bestLabel2, 9, 9, true, false);
|
||||
gd.verticalIndent = 10;
|
||||
|
||||
leftInner = new Composite(left,0);
|
||||
UiService.setGridLayout(leftInner, 1);
|
||||
UiService.setGridDataAuto(leftInner);
|
||||
|
||||
bestCollector = new WCollector(leftInner);
|
||||
|
||||
// Right
|
||||
Label worstLabel = new Label(right,0);
|
||||
worstLabel.setText("The WORST criterion is: ");
|
||||
UiService.setFont(worstLabel, UiService.FONT_SECTION_TITLE);
|
||||
|
||||
worstCombo = new Combo(right, SWT.READ_ONLY );
|
||||
gd = UiService.setGridData(worstCombo, 9, -1, true, false);
|
||||
gd.verticalIndent = 10;
|
||||
|
||||
Label worstLabel2 = new Label(right,0);
|
||||
worstLabel2.setText("Others -> Worst: (1-9) ");
|
||||
UiService.setFont(worstLabel2, UiService.FONT_SECTION_TITLE);
|
||||
gd = UiService.setGridData(worstLabel2, 9, 9, true, false);
|
||||
gd.verticalIndent = 10;
|
||||
|
||||
rightInner = new Composite(right,0);
|
||||
UiService.setGridLayout(rightInner, 1);
|
||||
UiService.setGridDataAuto(rightInner);
|
||||
|
||||
worstCollector = new WCollector(rightInner);
|
||||
|
||||
// Status
|
||||
SWTGraphicUtil.disableAllChildrenWidgets(leftInner);
|
||||
SWTGraphicUtil.disableAllChildrenWidgets(rightInner);
|
||||
|
||||
// Data
|
||||
String[] headers = model.getCriteriaNames();
|
||||
|
||||
bestCombo.setItems(headers);
|
||||
worstCombo.setItems(headers);
|
||||
|
||||
// Listeners
|
||||
bestCombo.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
||||
SWTGraphicUtil.enableAllChildrenWidgets(leftInner);
|
||||
bestCollector.setHeaders(headers);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
worstCombo.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
||||
SWTGraphicUtil.enableAllChildrenWidgets(rightInner);
|
||||
worstCollector.setHeaders(headers);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
bestCollector.setBeforeOperationListener(getCheckListener(true));
|
||||
worstCollector.setBeforeOperationListener(getCheckListener(false));
|
||||
|
||||
bestCollector.setChangeListener(getChangeListener(true));
|
||||
worstCollector.setChangeListener(getChangeListener(false));
|
||||
|
||||
Button execute = new Button(base, SWT.NONE);
|
||||
UiService.setGridData(execute, 9, 9, true, false);
|
||||
execute.setText("Execute");
|
||||
execute.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
model.execute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private WItemChanged getChangeListener(boolean best) {
|
||||
return new WItemChanged() {
|
||||
|
||||
@Override
|
||||
public void onWidgetChange() {
|
||||
ProblemElement[] subItems = model.getCriteria();
|
||||
|
||||
boolean status;
|
||||
if(best)
|
||||
status = addBestComparisons(subItems);
|
||||
else
|
||||
status = addWorstComparsions(subItems);
|
||||
|
||||
|
||||
sendRefresh();
|
||||
|
||||
selector.setStatus(currentItem, status);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private boolean addBestComparisons(ProblemElement[] subItems) {
|
||||
String[] data = bestCollector.getData();
|
||||
for (int i = 0; i < subItems.length && i < data.length; i++)
|
||||
model.setBestComparison(currentItem, subItems[i], data[i]);
|
||||
|
||||
return data.length == subItems.length;
|
||||
}
|
||||
|
||||
private boolean addWorstComparsions(ProblemElement[] subItems) {
|
||||
String[] data = worstCollector.getData();
|
||||
for (int i = 0; i < subItems.length && i < data.length; i++)
|
||||
model.setWorstComparison(currentItem, subItems[i], data[i]);
|
||||
|
||||
return data.length == subItems.length;
|
||||
}
|
||||
|
||||
private WItemBeforeOperation getCheckListener(boolean best) {
|
||||
return new WItemBeforeOperation() {
|
||||
|
||||
@Override
|
||||
public boolean shouldBeExecuted(WEvent operationType, String before, String after) {
|
||||
|
||||
if(operationType.equals(WEvent.ADD)) {
|
||||
|
||||
WCollector collector = (best) ? bestCollector : worstCollector;
|
||||
if(collector.getData().length == model.getCriteriaNames().length)
|
||||
return false;
|
||||
|
||||
int val = -1;
|
||||
try{
|
||||
val = Integer.parseInt(before);
|
||||
} catch(NumberFormatException e) {
|
||||
|
||||
}
|
||||
|
||||
if(val >= 1 && val <= 9)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void problemElementChanged(ProblemElement pe) {
|
||||
ProblemElement[] subItems = model.getCriteria();
|
||||
|
||||
currentItem = pe;
|
||||
|
||||
loadBestComparisons(subItems);
|
||||
loadWorstComparisons(subItems);
|
||||
}
|
||||
|
||||
private void loadBestComparisons(ProblemElement[] subItems) {
|
||||
ArrayList<String> data = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < subItems.length; i++) {
|
||||
String value = model.getBerstComparison(currentItem, subItems[i]);
|
||||
if (value != null)
|
||||
data.add(value);
|
||||
}
|
||||
|
||||
bestCollector.setValues(data);
|
||||
}
|
||||
|
||||
private void loadWorstComparisons(ProblemElement[] subItems) {
|
||||
ArrayList<String> data = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < subItems.length; i++) {
|
||||
String value = model.getWorstComparison(currentItem, subItems[i]);
|
||||
if (value != null)
|
||||
data.add(value);
|
||||
}
|
||||
|
||||
worstCollector.setValues(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isForwardEnabled() {
|
||||
return bestCollector.getData().length == model.getCriteriaNames().length && worstCollector.getData().length == model.getCriteriaNames().length;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user