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.collectweightsaggregation.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.collectweightsaggregation.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>1779484362649</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
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ui
|
||||
Bundle-SymbolicName: flintstones.method.common.phase.collectweightsaggregation.ui;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.common.phase.collectweightsaggregation.ui
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.entity.method.phase.ui,
|
||||
flintstones.method.common.phase.collectweightsaggregation,
|
||||
org.eclipse.swt,
|
||||
org.eclipse.jface,
|
||||
flintstones.model.ui.service,
|
||||
javax.inject,
|
||||
flintstones.model.problemelement.service,
|
||||
flintstones.entity.problemelement,
|
||||
flintstones.helper.data,
|
||||
org.eclipse.nebula.widgets.opal.notifier,
|
||||
flintstones.helper.ui,
|
||||
flintstones.entity.aggregation,
|
||||
flintstones.entity.common,
|
||||
org.lorissecuro.ui,
|
||||
org.eclipse.e4.core.services,
|
||||
org.eclipse.e4.core.contexts,
|
||||
org.eclipse.e4.core.di
|
||||
Import-Package: flintstones.entity.method.phase
|
||||
Export-Package: flintstones.method.common.phase.collectweightsaggregation.ui,
|
||||
flintstones.method.common.phase.collectweightsaggregation.ui.provider
|
||||
@@ -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.collectweightsaggregation.ui"
|
||||
implementation="flintstones.method.common.phase.collectweightsaggregation.ui.CollectWeightsAggregationUi"
|
||||
phasemethod="flintstones.method.common.phase.collectweightsaggregation">
|
||||
</phasemethod_ui>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+323
@@ -0,0 +1,323 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.jface.layout.GridLayoutFactory;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.TreeViewerColumn;
|
||||
import org.eclipse.nebula.widgets.opal.notifier.WNotifier;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.entity.common.interfaces.IChangedEntity;
|
||||
import flintstones.entity.common.interfaces.IRefreshEntity;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.helper.ui.components.ToggleButton;
|
||||
import flintstones.helper.ui.components.listeners.IToggle;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.CollectAggregationDataModel;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.messages.Messages;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.provider.EnabledColumnEditingSupport;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.provider.EnabledColumnLabelProvider;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.provider.MainColumnLabelProvider;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.provider.OperatorColumnEditingSupport;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.provider.OperatorColumnLabelProvider;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.provider.TreeContentProvider;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.provider.WeightColumnEditingSupport;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.provider.WeightColumnLabelProvider;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
|
||||
public class CollectAggregationDataUI implements IRefreshEntity {
|
||||
|
||||
CollectAggregationDataModel model;
|
||||
|
||||
// DATA
|
||||
AggregationItem mainItemExpert;
|
||||
AggregationItem mainItemCriterion;
|
||||
|
||||
// UI
|
||||
TreeViewer viewer;
|
||||
Label errorLabel;
|
||||
|
||||
// Type of aggregation
|
||||
boolean firstExpertsToAggregate = false;
|
||||
|
||||
IChangedEntity changedListener;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
Messages messages;
|
||||
|
||||
public CollectAggregationDataUI() {}
|
||||
|
||||
public CollectAggregationDataUI(CollectAggregationDataModel model, Composite base, Expert[] es, Criterion[] cs, Alternative[] as) {
|
||||
|
||||
this.model = model;
|
||||
mainItemExpert = new AggregationItem(new Alternative(""), es, cs); //$NON-NLS-1$
|
||||
mainItemCriterion = new AggregationItem(new Alternative(""), cs, es); //$NON-NLS-1$
|
||||
|
||||
// Weights
|
||||
mainItemExpert.shareWeight();
|
||||
mainItemCriterion.shareWeight();
|
||||
|
||||
drawTree(base);
|
||||
inputExpertCriterion();
|
||||
drawButtons(base);
|
||||
|
||||
errorLabel = new Label(base,0);
|
||||
errorLabel.setText(" "); //$NON-NLS-1$
|
||||
|
||||
refreshEntity(null);
|
||||
|
||||
}
|
||||
|
||||
public void build(CollectAggregationDataModel model, Composite base, Expert[] es, Criterion[] cs, Alternative[] as) {
|
||||
this.model = model;
|
||||
mainItemExpert = new AggregationItem(new Alternative(""), es, cs); //$NON-NLS-1$
|
||||
mainItemCriterion = new AggregationItem(new Alternative(""), cs, es); //$NON-NLS-1$
|
||||
|
||||
// Weights
|
||||
mainItemExpert.shareWeight();
|
||||
mainItemCriterion.shareWeight();
|
||||
|
||||
drawTree(base);
|
||||
inputExpertCriterion();
|
||||
drawButtons(base);
|
||||
|
||||
errorLabel = new Label(base,0);
|
||||
errorLabel.setText(" "); //$NON-NLS-1$
|
||||
|
||||
refreshEntity(null);
|
||||
}
|
||||
|
||||
private void inputExpertCriterion() {
|
||||
viewer.setInput(new AggregationItem[] {mainItemExpert});
|
||||
model.refreshExpertWeights(mainItemExpert);
|
||||
viewer.expandToLevel(3);
|
||||
}
|
||||
|
||||
private void inputCriterion() {
|
||||
viewer.setInput(new AggregationItem[] {mainItemCriterion});
|
||||
model.refreshCriterionWeights(mainItemCriterion);
|
||||
viewer.expandToLevel(3);
|
||||
}
|
||||
|
||||
private void drawButtons(Composite parent) {
|
||||
|
||||
Composite base = new Composite(parent,0);
|
||||
UiService.setGridData(base, 9, 0, true, false);
|
||||
UiService.setGridLayout(base, 3);
|
||||
|
||||
new ToggleButton(base, 0, new IToggle() {
|
||||
|
||||
@Override
|
||||
public void onBaseTextClick() {
|
||||
firstExpertsToAggregate = true;
|
||||
inputCriterion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAltTextClick() {
|
||||
firstExpertsToAggregate = false;
|
||||
inputExpertCriterion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseText() {
|
||||
return messages.First_criteria;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAltText() {
|
||||
return messages.First_experts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void always() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getBaseImage() {
|
||||
return null;
|
||||
//return UiService.getIcon("expertsFirst.png").createImage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getAltImage() {
|
||||
return null;
|
||||
//return UiService.getIcon("criteriaFirst.png").createImage();
|
||||
}
|
||||
});
|
||||
|
||||
Button applyToChildren = new Button(base, 0);
|
||||
applyToChildren.setText(messages.Apply_to_children);
|
||||
applyToChildren.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
IStructuredSelection selection = viewer.getStructuredSelection();
|
||||
AggregationItem aggItem = (AggregationItem) selection.getFirstElement();
|
||||
|
||||
// Check 1
|
||||
if(aggItem == null) {
|
||||
|
||||
new WNotifier("Error", messages.Select_element_first, WNotifier.Themes.YELLOW_THEME ) //$NON-NLS-1$
|
||||
.withCloseOnClick(true)
|
||||
.withTimeout(30)
|
||||
.send();
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
// Check 2
|
||||
String operatorId = aggItem.getOperatorId();
|
||||
if(operatorId.equals("")) { //$NON-NLS-1$
|
||||
new WNotifier("Error", messages.No_operator_selected, WNotifier.Themes.YELLOW_THEME ) //$NON-NLS-1$
|
||||
.withCloseOnClick(true)
|
||||
.withTimeout(30)
|
||||
.send();
|
||||
}
|
||||
|
||||
aggItem.setOperatorId(operatorId,true);
|
||||
viewer.refresh();
|
||||
refreshEntity(null);
|
||||
}
|
||||
});
|
||||
|
||||
Button applyToAll = new Button(base, 0);
|
||||
applyToAll.setText(messages.Fill_operators); //$NON-NLS-1$
|
||||
applyToAll.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
AggregationItem aggItem = (AggregationItem) viewer.getTree().getItems()[0].getData(); // First item of current viewer
|
||||
String operatorId = model.getOperatorsIdName().keySet().iterator().next();
|
||||
aggItem.setOperatorId(operatorId, true);
|
||||
viewer.refresh();
|
||||
refreshEntity(null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void drawTree(Composite parent) {
|
||||
|
||||
Composite base = new Composite(parent, 0);
|
||||
UiService.setGridDataAuto(base);
|
||||
UiService.setGridLayout(base, 1);
|
||||
|
||||
viewer = new TreeViewer(base, SWT.FULL_SELECTION);
|
||||
viewer.setContentProvider(new TreeContentProvider());
|
||||
viewer.getTree().setHeaderVisible(true);
|
||||
viewer.getTree().setLinesVisible(true);
|
||||
UiService.setGridData(viewer.getTree(), 9, 9, true, true);
|
||||
|
||||
TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.NONE);
|
||||
viewerColumn.getColumn().setText(messages.Element);
|
||||
viewerColumn.setLabelProvider(new MainColumnLabelProvider());
|
||||
|
||||
TreeViewerColumn viewerColumn2 = new TreeViewerColumn(viewer, SWT.NONE);
|
||||
viewerColumn2.getColumn().setText(messages.Weight);
|
||||
viewerColumn2.setLabelProvider(new WeightColumnLabelProvider());
|
||||
viewerColumn2.setEditingSupport(new WeightColumnEditingSupport(this, viewer));
|
||||
|
||||
TreeViewerColumn viewerColumn3 = new TreeViewerColumn(viewer, SWT.NONE);
|
||||
viewerColumn3.getColumn().setText(messages.Enabled);
|
||||
viewerColumn3.setLabelProvider(new EnabledColumnLabelProvider());
|
||||
viewerColumn3.setEditingSupport(new EnabledColumnEditingSupport(this, viewer));
|
||||
|
||||
TreeViewerColumn viewerColumn4 = new TreeViewerColumn(viewer, SWT.NONE);
|
||||
viewerColumn4.getColumn().setText(messages.Operator);
|
||||
viewerColumn4.setLabelProvider(new OperatorColumnLabelProvider(model.getOperatorsIdName(), messages));
|
||||
viewerColumn4.setEditingSupport(new OperatorColumnEditingSupport(this,viewer,model.getOperatorsNameId()));
|
||||
|
||||
|
||||
GridLayoutFactory.fillDefaults().generateLayout(parent);
|
||||
|
||||
// SIZE
|
||||
parent.addControlListener(new ControlAdapter() {
|
||||
@Override
|
||||
public void controlResized(ControlEvent e) {
|
||||
Composite composite = (Composite) e.widget;
|
||||
int width = composite.getBounds().width;
|
||||
|
||||
double total = 1.0d;
|
||||
double c2 = 0.1;
|
||||
double c3 = 0.12;
|
||||
double c4 = 0.3;
|
||||
double c1 = total -c2 -c3 -c4;
|
||||
|
||||
viewerColumn.getColumn().setWidth((int) (width*c1));
|
||||
viewerColumn2.getColumn().setWidth((int) (width*c2));
|
||||
viewerColumn3.getColumn().setWidth((int) (width*c3));
|
||||
viewerColumn4.getColumn().setWidth((int) (width*c4));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refreshEntity(Object x) {
|
||||
model.refreshExpertWeights(mainItemExpert);
|
||||
model.refreshCriterionWeights(mainItemCriterion);
|
||||
|
||||
String error = getFirstError();
|
||||
if(error != null)
|
||||
errorLabel.setText(error);
|
||||
else
|
||||
errorLabel.setText(""); //$NON-NLS-1$
|
||||
|
||||
if(changedListener != null)
|
||||
changedListener.onEntityChange(firstExpertsToAggregate);
|
||||
}
|
||||
|
||||
public void setChangeListener(IChangedEntity lis) {
|
||||
changedListener = lis;
|
||||
}
|
||||
|
||||
|
||||
public String getFirstError(){
|
||||
String err;
|
||||
if(firstExpertsToAggregate)
|
||||
err = getFirstError(mainItemCriterion);
|
||||
else
|
||||
err = getFirstError(mainItemExpert);
|
||||
|
||||
System.err.println(err);
|
||||
|
||||
return err;
|
||||
|
||||
}
|
||||
|
||||
private String getFirstError(AggregationItem item) {
|
||||
|
||||
|
||||
if(item.getOperatorId().equals("") && item.getElement3() == null) //$NON-NLS-1$
|
||||
return messages.Operator_not_defined_for_element + item.toString();
|
||||
|
||||
if(!item.validateWeights() && item.getElement3() == null )
|
||||
return messages.Weights_not_defined_for_element + item.toString();
|
||||
|
||||
for(AggregationItem child : item.getChildren()) {
|
||||
String err = getFirstError(child);
|
||||
if(err != null)
|
||||
return err;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isExpertFirst() {
|
||||
return !firstExpertsToAggregate;
|
||||
}
|
||||
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import flintstones.entity.method.phase.ui.PhaseMethodUI;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElementHelper;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.CollectAggregationDataModel;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
public class CollectWeightsAggregationUi extends PhaseMethodUI {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
CollectAggregationDataModel model;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
model = (CollectAggregationDataModel) getModel();
|
||||
|
||||
// CANVAS
|
||||
Composite base = getBaseComposite();
|
||||
UiService.setGridDataAuto(base);
|
||||
UiService.setGridLayout(base, 2);
|
||||
|
||||
//DATA
|
||||
Expert[] es = ProblemElementHelper.asExperts(problemService.getMainElements(Expert.Type));
|
||||
Criterion[] cs = ProblemElementHelper.asCriterions(problemService.getMainElements(Criterion.Type));
|
||||
Alternative[] as = ProblemElementHelper.asAlternatives(problemService.getMainElements(Alternative.Type));
|
||||
|
||||
CollectAggregationDataUI collectUi = ContextInjectionFactory.make(CollectAggregationDataUI.class, context);
|
||||
collectUi.build(model, base, es, cs, as);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isForwardEnabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui.messages;
|
||||
|
||||
public class Messages {
|
||||
|
||||
public String Apply_to_children;
|
||||
public String Element;
|
||||
public String Enabled;
|
||||
public String Fill_operators;
|
||||
public String First_criteria;
|
||||
public String First_experts;
|
||||
public String No_operator_selected;
|
||||
public String Operator;
|
||||
public String Operator_not_defined_for_element;
|
||||
public String Select_element_first;
|
||||
public String Weight;
|
||||
public String Weights_not_defined_for_element;
|
||||
public String Select_operator;
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
Apply_to_children=Apply to children
|
||||
Element=Element
|
||||
Enabled=Enabled
|
||||
Fill_operators=Fill operators
|
||||
First_criteria=First criteria
|
||||
First_experts=First experts
|
||||
No_operator_selected=No operator for the selected element.
|
||||
Operator=Operator
|
||||
Operator_not_defined_for_element=No operator for element
|
||||
Select_element_first=Select an element first.
|
||||
Weight=Weight
|
||||
Weights_not_defined_for_element=No weights for element
|
||||
Select_operator=- SELECT OPERATOR -
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
Apply_to_children=Aplicar a hijos
|
||||
Element=Elemento
|
||||
Enabled=Habilitado
|
||||
Fill_operators=Rellenar operadores
|
||||
First_criteria=Criterios primero
|
||||
First_experts=Expertos primero
|
||||
No_operator_selected=El elemento seleccionado no tiene un operador asignado.
|
||||
Operator=Operador
|
||||
Operator_not_defined_for_element=Operador no definido para el elemento.
|
||||
Select_element_first=Selecciona un elemento primero.
|
||||
Weight=Peso
|
||||
Weights_not_defined_for_element=Pesos no definidos para el elemento.
|
||||
Select_operator=- SELECCIONAR OPERADOR -
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui.provider;
|
||||
|
||||
import org.eclipse.jface.viewers.CellEditor;
|
||||
import org.eclipse.jface.viewers.EditingSupport;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.entity.common.interfaces.IRefreshEntity;
|
||||
|
||||
public class EnabledColumnEditingSupport extends EditingSupport {
|
||||
|
||||
private IRefreshEntity collectDataUi;
|
||||
|
||||
private final TreeViewer viewer;
|
||||
|
||||
public EnabledColumnEditingSupport(IRefreshEntity collectDataUi, TreeViewer viewer) {
|
||||
super(viewer);
|
||||
this.collectDataUi = collectDataUi;
|
||||
this.viewer = viewer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canEdit(Object element) {
|
||||
// Toggle onclick
|
||||
AggregationItem item = ((AggregationItem) element);
|
||||
|
||||
item.setEnabled(!item.isEnabled());
|
||||
viewer.update(element, null);
|
||||
viewer.setSelection(null);
|
||||
|
||||
if(item.getParent() != null)
|
||||
viewer.update(item.getParent(), null);
|
||||
|
||||
|
||||
if(item.validateParentWeights())
|
||||
this.collectDataUi.refreshEntity(null);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CellEditor getCellEditor(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getValue(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setValue(Object element, Object value) {
|
||||
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui.provider;
|
||||
|
||||
import org.eclipse.jface.viewers.ColumnLabelProvider;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
public class EnabledColumnLabelProvider extends ColumnLabelProvider {
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
return item.isEnabled() ? "Enabled" : "Disabled";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackground(Object element) {
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
if (item.isEnabled())
|
||||
return UiService.COLOR_BG_SUCCESS;
|
||||
return UiService.COLOR_BG_WRONG;
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui.provider;
|
||||
|
||||
import org.eclipse.jface.viewers.ColumnLabelProvider;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.entity.problemelement.entities.ProblemElementHelper;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
public class MainColumnLabelProvider extends ColumnLabelProvider {
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
return item.getFinalItem().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
String image = ProblemElementHelper.getImage(item.getFinalItem());
|
||||
return UiService.getImage(image).createImage();
|
||||
}
|
||||
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui.provider;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jface.viewers.CellEditor;
|
||||
import org.eclipse.jface.viewers.ComboBoxCellEditor;
|
||||
import org.eclipse.jface.viewers.EditingSupport;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.CCombo;
|
||||
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.entity.common.interfaces.IRefreshEntity;
|
||||
|
||||
public class OperatorColumnEditingSupport extends EditingSupport {
|
||||
|
||||
private IRefreshEntity collectDataUi;
|
||||
|
||||
private final TreeViewer viewer;
|
||||
|
||||
private ComboBoxCellEditor cellEditor;
|
||||
|
||||
private HashMap<String,String> operators;
|
||||
|
||||
public OperatorColumnEditingSupport(IRefreshEntity collectDataUi, TreeViewer viewer, HashMap<String,String> operators) {
|
||||
super(viewer);
|
||||
this.collectDataUi = collectDataUi;
|
||||
this.viewer = viewer;
|
||||
this.operators = operators;
|
||||
|
||||
cellEditor = new ComboBoxCellEditor(((TreeViewer) viewer).getTree(),operators.keySet().toArray(new String[0]), SWT.READ_ONLY);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CellEditor getCellEditor(Object element) {
|
||||
if (element instanceof AggregationItem)
|
||||
{
|
||||
return cellEditor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canEdit(Object element)
|
||||
{
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
if(item.getElement3() == null)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Object getValue(Object element)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setValue(Object element, Object value)
|
||||
{
|
||||
|
||||
CCombo combo = ((CCombo) cellEditor.getControl());
|
||||
String operatorName = combo.getItem(combo.getSelectionIndex());
|
||||
String operatorId = operators.get(operatorName);
|
||||
|
||||
// Update
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
item.setOperatorId(operatorId);
|
||||
viewer.update(element, null);
|
||||
// viewer.setSelection(null);
|
||||
|
||||
collectDataUi.refreshEntity(null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui.provider;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jface.viewers.ColumnLabelProvider;
|
||||
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.method.common.phase.collectweightsaggregation.ui.messages.Messages;
|
||||
|
||||
public class OperatorColumnLabelProvider extends ColumnLabelProvider {
|
||||
|
||||
Messages messages;
|
||||
|
||||
private HashMap<String,String> operators;
|
||||
|
||||
public OperatorColumnLabelProvider(HashMap<String,String> operators, Messages messages) {
|
||||
this.operators = operators;
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
String id = item.getOperatorId();
|
||||
String name = operators.get(id);
|
||||
|
||||
if(name == null) {
|
||||
if(item.getElement3() == null)
|
||||
return messages.Select_operator;
|
||||
else
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui.provider;
|
||||
|
||||
import org.eclipse.jface.viewers.ArrayContentProvider;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
|
||||
public class TreeContentProvider implements ITreeContentProvider {
|
||||
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
return item.hasChildren();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ArrayContentProvider.getInstance().getElements(inputElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
AggregationItem item = (AggregationItem) parentElement;
|
||||
return item.getChildren();
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui.provider;
|
||||
|
||||
import org.eclipse.jface.viewers.CellEditor;
|
||||
import org.eclipse.jface.viewers.EditingSupport;
|
||||
import org.eclipse.jface.viewers.TextCellEditor;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.entity.common.interfaces.IRefreshEntity;
|
||||
import flintstones.helper.DoubleHelper;
|
||||
|
||||
public class WeightColumnEditingSupport extends EditingSupport {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private IRefreshEntity collectWeightsAggregationUi;
|
||||
private final TreeViewer viewer;
|
||||
private final CellEditor editor;
|
||||
|
||||
public WeightColumnEditingSupport(IRefreshEntity collectDataUi, TreeViewer viewer) {
|
||||
super(viewer);
|
||||
this.collectWeightsAggregationUi = collectDataUi;
|
||||
this.viewer = viewer;
|
||||
this.editor = new TextCellEditor(viewer.getTree());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CellEditor getCellEditor(Object element) {
|
||||
return editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canEdit(Object element) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getValue(Object element) {
|
||||
return ((AggregationItem) element).getWeight() + "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setValue(Object element, Object userInputValue) {
|
||||
|
||||
String sval = userInputValue.toString();
|
||||
double val = DoubleHelper.ParseDouble(sval);
|
||||
if (val > 1.0)
|
||||
val = DoubleHelper.NormalizeZeroToOne(sval);
|
||||
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
((AggregationItem) element).setWeight(val);
|
||||
|
||||
// Update things
|
||||
viewer.update(element, null);
|
||||
if(item.getParent() != null) {
|
||||
viewer.update(item.getParent(), null);
|
||||
if(item.validateParentWeights())
|
||||
this.collectWeightsAggregationUi.refreshEntity(null);
|
||||
}
|
||||
|
||||
// viewer.setSelection(null);
|
||||
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package flintstones.method.common.phase.collectweightsaggregation.ui.provider;
|
||||
|
||||
import org.eclipse.jface.viewers.ColumnLabelProvider;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
|
||||
import flintstones.entity.aggregation.AggregationItem;
|
||||
import flintstones.helper.DoubleHelper;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
|
||||
public class WeightColumnLabelProvider extends ColumnLabelProvider {
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
return DoubleHelper.Draw(item.getWeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackground(Object element) {
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
|
||||
if(!item.isEnabled())
|
||||
return UiService.COLOR_BG_NORMAL;
|
||||
|
||||
if (!item.hasChildren())
|
||||
return UiService.COLOR_BG_NORMAL;
|
||||
|
||||
if (item.validateWeights())
|
||||
return UiService.COLOR_BG_SUCCESS;
|
||||
|
||||
return UiService.COLOR_BG_WRONG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getForeground(Object element) {
|
||||
|
||||
AggregationItem item = (AggregationItem) element;
|
||||
|
||||
if(!item.isEnabled())
|
||||
return UiService.COLOR_BG_NORMAL;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user