public code v1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?flintstones.helper.data.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>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?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.application.perspective.frameworkstructuring.ui</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] FrameworkStructuringUI</name>
|
||||
<organization>
|
||||
<name>Sinbad2</name>
|
||||
</organization>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.application.perspective.frameworkstructuring.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>1779484362527</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
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %Bundle-Name
|
||||
Bundle-SymbolicName: flintstones.application.perspective.frameworkstructuring.ui;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: %Bundle-Vendor
|
||||
Require-Bundle: flintstones.element.common.ui,
|
||||
flintstones.helper.ui,
|
||||
flintstones.helper.debug,
|
||||
flintstones.model.problemelement.service,
|
||||
javax.inject,
|
||||
org.eclipse.e4.core.services,
|
||||
org.eclipse.e4.core.contexts,
|
||||
flintstones.model.domain.service,
|
||||
org.eclipse.e4.core.di,
|
||||
flintstones.entity.valuation,
|
||||
flintstones.model.valuation.service,
|
||||
javax.annotation,
|
||||
flintstones.model.ui.service,
|
||||
flintstones.application.perspective.framework.ui,
|
||||
org.lorissecuro.ui
|
||||
Automatic-Module-Name: flintstones.frameworkstructuring.ui
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
#Properties file for flintstones.frameworkstructuring.ui
|
||||
Bundle-Vendor = Sinbad2
|
||||
Bundle-Name = FrameworkStructuringUI
|
||||
flintstones.frameworkstructuring.ui.part.assignmentsprovider.label = Assignments Provider
|
||||
flintstones.frameworkstructuring.ui.part.elements = Elements
|
||||
flintstones.frameworkstructuring.ui.part.domainindex = Domain Index
|
||||
flintstones.frameworkstructuring.ui.part.elementassignments = Element Assignments
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
|
||||
flintstones.frameworkstructuring.ui.part.assignmentsprovider.label = Proveedor de asignaciones
|
||||
flintstones.frameworkstructuring.ui.part.elements = Elementos
|
||||
flintstones.frameworkstructuring.ui.part.domainindex = Índice de dominios
|
||||
flintstones.frameworkstructuring.ui.part.elementassignments = Asignación de elementos
|
||||
@@ -0,0 +1,8 @@
|
||||
output.. = bin/
|
||||
bin.includes = plugin.xml,\
|
||||
META-INF/,\
|
||||
.,\
|
||||
fragment.e4xmi,\
|
||||
OSGI-INF/l10n/bundle.properties,\
|
||||
OSGI-INF/
|
||||
source.. = src/
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_t-9jYAj8EeiQ0qVR_gLhbA">
|
||||
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_J8ENQDlqEeiRAZAz6MpOhg" featurename="commands" parentElementId="flintstones.application.application">
|
||||
<elements xsi:type="commands:Command" xmi:id="_QaiskDlqEeiRAZAz6MpOhg" elementId="flintstones.frameworkstructuring.ui.command.transpose" commandName="Transpose"/>
|
||||
</fragments>
|
||||
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_VSw_wDlqEeiRAZAz6MpOhg" featurename="handlers" parentElementId="flintstones.application.application">
|
||||
<elements xsi:type="commands:Handler" xmi:id="_XJhtEDlqEeiRAZAz6MpOhg" elementId="flintstones.frameworkstructuring.ui.handler.transpose" contributionURI="bundleclass://flintstones.application.perspective.gathering.ui/flintstones.application.perspective.gathering.ui.handlers.TransposeHandler" command="_QaiskDlqEeiRAZAz6MpOhg"/>
|
||||
</fragments>
|
||||
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_7c-9ILAQEeihksCysMAItw" featurename="children" parentElementId="flintstones.application.perspectivestack.modes">
|
||||
<elements xsi:type="advanced:Perspective" xmi:id="_7c-9IbAQEeihksCysMAItw" elementId="flintstones.application.perspective.frameworkstructuring" label="%flintstones.application.perspective.frameworkstructuring.label">
|
||||
<children xsi:type="basic:PartSashContainer" xmi:id="_LUyYcAj-EeiQ0qVR_gLhbA" elementId="flintstones.application.partsashcontainer.frameworkstructuring">
|
||||
<children xsi:type="basic:PartStack" xmi:id="_OBOJgAj-EeiQ0qVR_gLhbA" elementId="flintstones.application.partstack.assignmentsprovider" containerData="650">
|
||||
<children xsi:type="basic:Part" xmi:id="_vJeccAkBEeiQ0qVR_gLhbA" elementId="flintstones.frameworkstructuring.ui.part.assignmentsprovider" contributionURI="bundleclass://flintstones.application.perspective.frameworkstructuring.ui/flintstones.application.perspective.frameworkstructuring.ui.parts.AssignmentsProviderPart" label="%flintstones.frameworkstructuring.ui.part.assignmentsprovider.label" iconURI="platform:/plugin/flintstones.model.ui.service/icons/elementassignmentstable.png"/>
|
||||
</children>
|
||||
<children xsi:type="basic:PartSashContainer" xmi:id="_NFtjgAj-EeiQ0qVR_gLhbA" elementId="flintstones.application.partsashcontainer.bottom" horizontal="true">
|
||||
<children xsi:type="basic:PartSashContainer" xmi:id="_T1iRgAj-EeiQ0qVR_gLhbA" elementId="flintstones.application.partsashcontainer.left" containerData="1800">
|
||||
<children xsi:type="basic:Part" xmi:id="_x90hcAkDEeiQ0qVR_gLhbA" elementId="flintstones.frameworkstructuring.ui.part.elements" contributionURI="bundleclass://flintstones.application.perspective.frameworkstructuring.ui/flintstones.application.perspective.frameworkstructuring.ui.parts.ElementPart" label="%flintstones.frameworkstructuring.ui.part.elements" iconURI="platform:/plugin/flintstones.model.ui.service/icons/element.png">
|
||||
<properties key="Type" value="Expert"/>
|
||||
</children>
|
||||
<children xsi:type="basic:Part" xmi:id="_ihziIHe3EemHI7uE3cdyIA" elementId="flintstones.frameworkstructuring.ui.part.elements" contributionURI="bundleclass://flintstones.application.perspective.frameworkstructuring.ui/flintstones.application.perspective.frameworkstructuring.ui.parts.ElementPart" label="%flintstones.frameworkstructuring.ui.part.elements" iconURI="platform:/plugin/flintstones.model.ui.service/icons/element.png">
|
||||
<properties key="Type" value="Criterion"/>
|
||||
</children>
|
||||
<children xsi:type="basic:Part" xmi:id="_imvFcHe3EemHI7uE3cdyIA" elementId="flintstones.frameworkstructuring.ui.part.elements" contributionURI="bundleclass://flintstones.application.perspective.frameworkstructuring.ui/flintstones.application.perspective.frameworkstructuring.ui.parts.ElementPart" label="%flintstones.frameworkstructuring.ui.part.elements" iconURI="platform:/plugin/flintstones.model.ui.service/icons/element.png">
|
||||
<properties key="Type" value="Alternative"/>
|
||||
</children>
|
||||
</children>
|
||||
<children xsi:type="basic:PartStack" xmi:id="_MNTU0Aj-EeiQ0qVR_gLhbA" elementId="flintstones.application.partstack.elementassignments">
|
||||
<children xsi:type="basic:Part" xmi:id="_7VzkgAkDEeiQ0qVR_gLhbA" elementId="flintstones.frameworkstructuring.ui.part.elementassignments" contributionURI="bundleclass://flintstones.application.perspective.frameworkstructuring.ui/flintstones.application.perspective.frameworkstructuring.ui.parts.ElementsAssignmentPart" label="%flintstones.frameworkstructuring.ui.part.elementassignments" iconURI="platform:/plugin/flintstones.model.ui.service/icons/elementassignmentstable.png">
|
||||
<persistedState key="perspective" value="fs"/>
|
||||
<toolbar xmi:id="_musEEDlqEeiRAZAz6MpOhg" elementId="flintstones.frameworkstructuring.ui.toolbar.0">
|
||||
<children xsi:type="menu:HandledToolItem" xmi:id="_nZSgQDlqEeiRAZAz6MpOhg" elementId="flintstones.frameworkstructuring.ui.handledtoolitem.transpose" label="Transpose" iconURI="platform:/plugin/flintstones.model.ui.service/icons/transpose.png" tooltip="Transpose" command="_QaiskDlqEeiRAZAz6MpOhg"/>
|
||||
</toolbar>
|
||||
</children>
|
||||
</children>
|
||||
</children>
|
||||
</children>
|
||||
</elements>
|
||||
</fragments>
|
||||
</fragment:ModelFragments>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
|
||||
<extension
|
||||
id="flintstones.frameworkstructuring.ui.fragment"
|
||||
point="org.eclipse.e4.workbench.model">
|
||||
<fragment
|
||||
uri="fragment.e4xmi">
|
||||
</fragment>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.application.perspective.frameworkstructuring.ui.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
|
||||
public String ElementsAssignmentStack_title_template;
|
||||
public String AssignmentsProviderStack_appy;
|
||||
public String WILDCARD;
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
ElementsAssignmentStack_title_template= {0} | {1}
|
||||
AssignmentsProviderStack_appy=Apply
|
||||
WILDCARD=* (All)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
ElementsAssignmentStack_title_template= {0} | {1}
|
||||
AssignmentsProviderStack_appy=Aplicar
|
||||
WILDCARD=* (Todos)
|
||||
+365
@@ -0,0 +1,365 @@
|
||||
package flintstones.application.perspective.frameworkstructuring.ui.parts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.di.annotations.Optional;
|
||||
import org.eclipse.e4.core.services.events.IEventBroker;
|
||||
import org.eclipse.e4.core.services.nls.ILocaleChangeService;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.e4.ui.di.UIEventTopic;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import flintstones.application.constants.FrameworkConstants;
|
||||
import flintstones.application.perspective.frameworkstructuring.ui.messages.Messages;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.problemelement.ProblemElementKey;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.ui.components.ActionButton;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
import flintstones.model.valuation.service.IValuationService;
|
||||
|
||||
/**
|
||||
* The Class AssignmentsProviderStack.
|
||||
*/
|
||||
public class AssignmentsProviderPart {
|
||||
|
||||
/** The valuation service. */
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
/** The domain service. */
|
||||
@Inject
|
||||
IDomainService domainService;
|
||||
|
||||
/** The problem service. */
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
/** The context. */
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
/** The broker. */
|
||||
@Inject
|
||||
IEventBroker broker;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private flintstones.entity.domain.messages.Messages domainMessages;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private flintstones.entity.problemelement.messages.Messages problemMessages;
|
||||
|
||||
/** The expert combo. */
|
||||
Combo expertCombo;
|
||||
|
||||
/** The criterion combo. */
|
||||
Combo criterionCombo;
|
||||
|
||||
/** The alternative combo. */
|
||||
Combo alternativeCombo;
|
||||
|
||||
/** The domain combo. */
|
||||
Combo domainCombo;
|
||||
|
||||
// Translatable
|
||||
private Label expertLabel;
|
||||
private Label alternativeLabel;
|
||||
private Label criterionLabel;
|
||||
private Label domainLabel;
|
||||
private ActionButton apply;
|
||||
|
||||
/**
|
||||
* Creates the controls.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
@PostConstruct
|
||||
public void createControls(Composite parent) {
|
||||
|
||||
// Create 4 combo boxes plus 1 button to apply
|
||||
UiService.setGridLayout(parent, 9, false);
|
||||
UiService.setGridData(parent, 9, 9, true, true);
|
||||
|
||||
Composite l = new Composite(parent, 0);
|
||||
UiService.setGridLayout(l, 8, false);
|
||||
UiService.setGridData(l, 9, 1, true, false);
|
||||
|
||||
Composite r = new Composite(parent, 0);
|
||||
UiService.setGridLayout(r, 1, true);
|
||||
UiService.setGridData(r, 9, 1, false, false);
|
||||
|
||||
this.createCombos(l);
|
||||
this.createButton(r);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the label combo.
|
||||
*
|
||||
* @param parent the parent
|
||||
* @param text the label
|
||||
* @return the combo
|
||||
*/
|
||||
private Combo createCombo(Composite parent, String type) {
|
||||
Combo combo = new Combo(parent, SWT.READ_ONLY);
|
||||
|
||||
if (type != null) {
|
||||
combo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
//String name = combo.getText();
|
||||
//ProblemElement element = problemService.getByName(type, name);
|
||||
//broker.post(FrameworkConstants.TOPIC_SELECTION_FRAMEWORK_PROBLEMELEMENT, element);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
UiService.setGridData(combo, 9, 1, true, false);
|
||||
|
||||
return combo;
|
||||
}
|
||||
|
||||
private Label createLabel(Composite parent) {
|
||||
Label label = new Label(parent, SWT.LEFT);
|
||||
UiService.setGridData(label, -1, 0, false, false);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
private void drawLabelCombo(Label label, Combo combo, String text) {
|
||||
label.setText(text);
|
||||
combo.setText(text);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates the combo.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
public void createCombos(Composite parent) {
|
||||
|
||||
// EXPERTS
|
||||
this.expertLabel = this.createLabel(parent);
|
||||
this.expertCombo = this.createCombo(parent, Expert.Type);
|
||||
|
||||
// CRITERION
|
||||
this.criterionLabel = this.createLabel(parent);
|
||||
this.criterionCombo = this.createCombo(parent, Criterion.Type);
|
||||
|
||||
// ALTERNATIVE
|
||||
this.alternativeLabel = this.createLabel(parent);
|
||||
this.alternativeCombo = this.createCombo(parent, Alternative.Type);
|
||||
|
||||
// DOMAIN
|
||||
this.domainLabel = this.createLabel(parent);
|
||||
this.domainCombo = this.createCombo(parent, null);
|
||||
|
||||
// Set Placeholder Texts
|
||||
this.drawCombos();
|
||||
}
|
||||
|
||||
private void drawCombos() {
|
||||
|
||||
this.expertCombo.removeAll();
|
||||
this.criterionCombo.removeAll();
|
||||
this.alternativeCombo.removeAll();
|
||||
this.domainCombo.removeAll();
|
||||
|
||||
this.drawLabelCombo(this.expertLabel, this.expertCombo, this.problemMessages.EXPERT_ENTITY_NAME);
|
||||
this.drawLabelCombo(this.criterionLabel, this.criterionCombo, this.problemMessages.CRITERION_ENTITY_NAME);
|
||||
this.drawLabelCombo(this.alternativeLabel, this.alternativeCombo, this.problemMessages.ALTERNATIVE_ENTITY_NAME);
|
||||
this.drawLabelCombo(this.domainLabel, this.domainCombo, this.domainMessages.Domain_entity);
|
||||
|
||||
this.setExperts();
|
||||
this.setCriterion();
|
||||
this.setAlternatives();
|
||||
this.setDomains();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the domains.
|
||||
*/
|
||||
private void setDomains() {
|
||||
|
||||
Domain[] domainArr = this.domainService.getAll();
|
||||
for (Domain d : domainArr)
|
||||
this.domainCombo.add(d.getName());
|
||||
|
||||
if (domainArr.length > 0)
|
||||
domainCombo.select(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the alternatives.
|
||||
*/
|
||||
private void setAlternatives() {
|
||||
|
||||
this.alternativeCombo.add(this.messages.WILDCARD);
|
||||
this.alternativeCombo.select(0);
|
||||
|
||||
for (ProblemElement a : this.problemService.getSubElements(Alternative.Type))
|
||||
this.alternativeCombo.add(a.getName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the criterion.
|
||||
*/
|
||||
private void setCriterion() {
|
||||
|
||||
this.criterionCombo.add(this.messages.WILDCARD);
|
||||
this.criterionCombo.select(0);
|
||||
|
||||
for (ProblemElement a : this.problemService.getSubElements(Criterion.Type))
|
||||
this.criterionCombo.add(a.getName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the experts.
|
||||
*/
|
||||
private void setExperts() {
|
||||
this.expertCombo.add(this.messages.WILDCARD);
|
||||
this.expertCombo.select(0);
|
||||
|
||||
for (ProblemElement a : this.problemService.getSubElements(Expert.Type))
|
||||
this.expertCombo.add(a.getName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the button.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
public void createButton(Composite parent) {
|
||||
|
||||
this.apply = new ActionButton(parent, 0, 12);
|
||||
UiService.setGridData(apply.getButton(), -1, 1, true, false);
|
||||
apply.setHeight(30);
|
||||
|
||||
apply.getButton().setMarginHeight(0);
|
||||
apply.getButton().setMarginWidth(0);
|
||||
this.drawButton();
|
||||
|
||||
this.apply.getButton().addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseUp(MouseEvent e) {
|
||||
buttonClick();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void drawButton() {
|
||||
this.apply.setText(this.messages.AssignmentsProviderStack_appy);
|
||||
}
|
||||
|
||||
private void buttonClick() {
|
||||
// 1. Grab IDs from ComboBoxes
|
||||
String expertId = expertCombo.getText();
|
||||
String criterionId = criterionCombo.getText();
|
||||
String alternativeId = alternativeCombo.getText();
|
||||
String domainId = domainCombo.getText();
|
||||
|
||||
// If there is no domain there is nothing to do
|
||||
if (domainId.equals("")) //$NON-NLS-1$
|
||||
return;
|
||||
|
||||
// Fill some lists with the posible items
|
||||
ArrayList<ProblemElement> experts = new ArrayList<>();
|
||||
ArrayList<ProblemElement> criterions = new ArrayList<>();
|
||||
ArrayList<ProblemElement> alternatives = new ArrayList<>();
|
||||
|
||||
if (expertId.equals(messages.WILDCARD))
|
||||
experts.addAll(Arrays.asList(problemService.getSubElements(Expert.Type)));
|
||||
else {
|
||||
ProblemElement e1 = problemService.getByName(Expert.Type, expertId);
|
||||
experts.add(e1);
|
||||
}
|
||||
|
||||
if (criterionId.equals(messages.WILDCARD))
|
||||
criterions.addAll(Arrays.asList(problemService.getSubElements(Criterion.Type)));
|
||||
else {
|
||||
ProblemElement c1 = problemService.getByName(Criterion.Type, criterionId);
|
||||
criterions.add(c1);
|
||||
}
|
||||
|
||||
if (alternativeId.equals(messages.WILDCARD))
|
||||
alternatives.addAll(Arrays.asList(problemService.getSubElements(Alternative.Type)));
|
||||
else {
|
||||
ProblemElement a1 = problemService.getByName(Alternative.Type, alternativeId);
|
||||
alternatives.add(a1);
|
||||
}
|
||||
|
||||
Domain d1 = domainService.getByName(domainId);
|
||||
|
||||
// Create a valuation for each one
|
||||
for (ProblemElement ei : experts)
|
||||
for (ProblemElement ai : alternatives)
|
||||
for (ProblemElement ci : criterions) {
|
||||
ProblemElementKey pek = new ProblemElementKey((Expert) ei, (Alternative) ai, (Criterion) ci);
|
||||
Valuation v = valuationService.create(d1);
|
||||
valuationService.addOrUpdate(pek, v);
|
||||
}
|
||||
|
||||
broker.post(FrameworkConstants.TOPIC_VALUATION_CREATED, null);
|
||||
broker.post(FrameworkConstants.TOPIC_VALUATION_ASSIGNED, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribe(@UIEventTopic(FrameworkConstants.TOPIC_FRAMEWORK_ALLTOPICS) Object o) {
|
||||
this.drawCombos();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeModifiedDomain(@UIEventTopic(FrameworkConstants.TOPIC_FRAMEWORK_DOMAIN_MODIFIED) Object o) {
|
||||
this.drawCombos();
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void getNotified(@UIEventTopic(ILocaleChangeService.LOCALE_CHANGE) Locale s) {
|
||||
this.drawCombos();
|
||||
this.drawButton();
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package flintstones.application.perspective.frameworkstructuring.ui.parts;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.di.annotations.Optional;
|
||||
import org.eclipse.e4.ui.di.UIEventTopic;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import flintstones.application.constants.FrameworkConstants;
|
||||
import flintstones.element.common.ui.views.DomainViewer;
|
||||
|
||||
/**
|
||||
* The Class DomainIndexStack.
|
||||
*/
|
||||
public class DomainIndexPart {
|
||||
|
||||
/** The context. */
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
/** The domain viewer. */
|
||||
DomainViewer viewer;
|
||||
|
||||
/** The Constant SUB_ID. */
|
||||
private static final String SUB_ID = FrameworkConstants.TOPIC_FRAMEWORK_DOMAIN_ALLTOPICS;
|
||||
|
||||
/**
|
||||
* Inits the part.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init(Composite parent) {
|
||||
this.viewer = ContextInjectionFactory.make(DomainViewer.class, this.context);
|
||||
this.viewer.createControls(parent, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribe(@UIEventTopic(DomainIndexPart.SUB_ID) Map<String, String> event) {
|
||||
this.viewer.updateViewer();
|
||||
}
|
||||
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package flintstones.application.perspective.frameworkstructuring.ui.parts;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.di.annotations.Optional;
|
||||
import org.eclipse.e4.core.services.events.IEventBroker;
|
||||
import org.eclipse.e4.ui.di.UIEventTopic;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import flintstones.application.constants.FrameworkConstants;
|
||||
import flintstones.application.perspective.framework.ui.viewer.ProblemElementViewerV2;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
|
||||
/**
|
||||
* @author UJA
|
||||
* postConstruct
|
||||
*/
|
||||
public class ElementPart {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
@Inject
|
||||
IEventBroker broker;
|
||||
|
||||
private static final String SUB_ID = FrameworkConstants.TOPIC_FRAMEWORK_ALLTOPICS;
|
||||
|
||||
/**
|
||||
* Function called after the construction of our MPart, basically creates the structure of the
|
||||
* TableViewer and adds the data that has been added in the Framework perspective.
|
||||
* @param parent
|
||||
*/
|
||||
|
||||
ProblemElementViewerV2 viewer;
|
||||
|
||||
@PostConstruct
|
||||
public void createControls(Composite base) {
|
||||
|
||||
String type = (String) context.get("Type");
|
||||
|
||||
ProblemElement[] pes = problemService.getSubElements(type);
|
||||
|
||||
viewer = new ProblemElementViewerV2()
|
||||
.isOpenedOnClick(true)
|
||||
.isModifiedOnDoubleClick(false)
|
||||
.isDragAndDropEnabled(false)
|
||||
.drawViewer(base, pes, type);
|
||||
|
||||
ContextInjectionFactory.inject(viewer, context);
|
||||
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribe(@UIEventTopic(ElementPart.SUB_ID) Map<String, String> event) {
|
||||
String type = (String) context.get("Type");
|
||||
ProblemElement[] pes = problemService.getSubElements(type);
|
||||
this.viewer.refresh(pes);
|
||||
}
|
||||
}
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
|
||||
package flintstones.application.perspective.frameworkstructuring.ui.parts;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.di.annotations.Optional;
|
||||
import org.eclipse.e4.core.services.nls.ILocaleChangeService;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.e4.ui.di.UIEventTopic;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import flintstones.application.constants.FrameworkConstants;
|
||||
import flintstones.application.perspective.frameworkstructuring.ui.messages.Messages;
|
||||
import flintstones.element.common.ui.providers.AssignmentsTableProvider;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.FakeProblemElement;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.helper.debug.DH;
|
||||
import flintstones.helper.wtable.WTable;
|
||||
import flintstones.helper.wtable.WTableModel;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.valuation.service.IValuationService;
|
||||
|
||||
/**
|
||||
* The Class ElementsAssignmentStack.
|
||||
*/
|
||||
public class ElementsAssignmentPart {
|
||||
|
||||
/** The problem service. */
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
/** The valuation service. */
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
/** The domain service. */
|
||||
@Inject
|
||||
IDomainService domainService;
|
||||
|
||||
/** The context. */
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
/** The part. */
|
||||
@Inject
|
||||
MPart part;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private flintstones.entity.domain.messages.Messages domainMessages;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private flintstones.entity.problemelement.messages.Messages problemMessages;
|
||||
|
||||
/** The table. */
|
||||
private WTable wtable;
|
||||
|
||||
/** The table model. */
|
||||
private WTableModel tableModel;
|
||||
|
||||
/** The table provider. */
|
||||
private AssignmentsTableProvider provider;
|
||||
|
||||
/** The current problem element. */
|
||||
private ProblemElement currentProblemElement;
|
||||
|
||||
/** The base composite. */
|
||||
private Composite baseComposite;
|
||||
|
||||
/** is the table transposed */
|
||||
private boolean isTransposed = false;
|
||||
|
||||
/** The Constant SUB_ID_PROBLEM. */
|
||||
private static final String SUB_ID_PROBLEM = FrameworkConstants.TOPIC_FRAMEWORK_ALLTOPICS;
|
||||
|
||||
/** The Constant SUB_ID_SELECTION. */
|
||||
private static final String SUB_ID_SELECTION = FrameworkConstants.TOPIC_SELECTION_FRAMEWORK_PROBLEMELEMENT;
|
||||
|
||||
/** The Constant SUB_ID_TRANSPOSE. */
|
||||
private static final String SUB_ID_TRANSPOSE = "TOPIC/COMMAND/TRANSPOSE"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Inits the part.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init(Composite parent) {
|
||||
|
||||
this.baseComposite = parent;
|
||||
parent.getParent().setLayout(new FillLayout());
|
||||
|
||||
ProblemElement[] items = this.problemService.getAll(Expert.Type);
|
||||
|
||||
if (items.length > 0)
|
||||
this.initPart(items[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw table.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
private void drawTable(Composite parent) {
|
||||
Composite cc = new Composite(parent, SWT.NONE);
|
||||
cc.setLayout(new FillLayout());
|
||||
this.wtable = new WTable(cc, SWT.V_SCROLL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh table.
|
||||
*/
|
||||
public void refreshTable() {
|
||||
if (this.currentProblemElement != null)
|
||||
this.initPart(this.currentProblemElement);
|
||||
baseComposite.layout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the part.
|
||||
*
|
||||
* @param pe Problem Element
|
||||
* Draw a table for the given Problem Element
|
||||
*/
|
||||
public void initPart(ProblemElement pe) {
|
||||
|
||||
if (this.wtable == null)
|
||||
this.drawTable(this.baseComposite);
|
||||
|
||||
this.currentProblemElement = pe;
|
||||
|
||||
// Part title
|
||||
this.drawPartTitle();
|
||||
|
||||
// Table
|
||||
this.provider = ContextInjectionFactory.make(AssignmentsTableProvider.class, this.context);
|
||||
this.provider.show(Domain.Fields.Domain.toString());
|
||||
this.provider.prepareTableContent(pe);
|
||||
|
||||
if (this.isTransposed)
|
||||
this.provider.transpose();
|
||||
|
||||
this.setTable();
|
||||
}
|
||||
|
||||
private void drawPartTitle() {
|
||||
ProblemElement pe = this.currentProblemElement;
|
||||
String template = this.messages.ElementsAssignmentStack_title_template;
|
||||
|
||||
String type = pe.getType();
|
||||
String label = ""; //$NON-NLS-1$
|
||||
|
||||
if (type.equals(Alternative.Type))
|
||||
label = this.problemMessages.ALTERNATIVE_ENTITY_NAME;
|
||||
else if (type.equals(Criterion.Type))
|
||||
label = this.problemMessages.CRITERION_ENTITY_NAME;
|
||||
else if (type.equals(Expert.Type))
|
||||
label = this.problemMessages.EXPERT_ENTITY_NAME;
|
||||
|
||||
String message = MessageFormat.format(template, label, pe.getCanonicalName());
|
||||
this.part.setLabel(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the table.
|
||||
*/
|
||||
private void setTable() {
|
||||
|
||||
// Clear last table listener if it exists
|
||||
if (this.tableModel != null)
|
||||
this.tableModel.clearListeners();
|
||||
|
||||
this.tableModel = new WTableModel(this.wtable);
|
||||
|
||||
// Cabeceras
|
||||
this.tableModel.setHorizontalHeaders(this.provider.getTableHeaderH());
|
||||
this.tableModel.setVerticalHeaders(this.provider.getTableHeaderV());
|
||||
|
||||
// Contenido, PH, Abbr
|
||||
this.tableModel.addContent(this.provider.getTableValuations());
|
||||
|
||||
this.wtable.setModel(this.tableModel);
|
||||
this.tableModel.init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subscribe selection.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeSelectionAlt(@UIEventTopic(ElementsAssignmentPart.SUB_ID_SELECTION) ProblemElement pe) {
|
||||
|
||||
if(pe != null && !(pe instanceof FakeProblemElement)) {
|
||||
this.initPart(pe);
|
||||
this.refreshTable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe problem.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeProblem(@UIEventTopic(ElementsAssignmentPart.SUB_ID_PROBLEM) Map<String, String> event) {
|
||||
this.refreshTable();
|
||||
|
||||
DH.out("refresh", "refreshTable");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe transpose.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeTranspose(@UIEventTopic(ElementsAssignmentPart.SUB_ID_TRANSPOSE) Map<String, Object> event) {
|
||||
DH.out("refresh", "subscribeTranspose");
|
||||
|
||||
if (this.currentProblemElement != null) {
|
||||
this.provider.transpose();
|
||||
this.setTable();
|
||||
this.isTransposed = !this.isTransposed;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void getNotified(@UIEventTopic(ILocaleChangeService.LOCALE_CHANGE) Locale s) {
|
||||
DH.out("refresh", "getNotified");
|
||||
|
||||
this.drawPartTitle();
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeFrameworkstructuring(@UIEventTopic(FrameworkConstants.TOPIC_VALUATION_ASSIGNED) Object o) {
|
||||
ProblemElement[] items = this.problemService.getAll(Expert.Type);
|
||||
if (items.length > 0)
|
||||
refreshTable();
|
||||
DH.out("refresh", "subscribeFrameworkstructuring");
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeFramework(@UIEventTopic(FrameworkConstants.TOPIC_FRAMEWORK_DOMAIN_CREATED) Object o) {
|
||||
ProblemElement[] items = this.problemService.getAll(Expert.Type);
|
||||
if (items.length > 0)
|
||||
this.initPart(items[0]);
|
||||
DH.out("refresh", "subscribeFramework");
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeFramework2(@UIEventTopic(FrameworkConstants.TOPIC_FRAMEWORK_PROBLEMELEMENT_ALLTOPICS) Object o) {
|
||||
ProblemElement[] items = this.problemService.getAll(Expert.Type);
|
||||
if (items.length > 0)
|
||||
this.initPart(items[0]);
|
||||
DH.out("refresh", "subscribeFramework");
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeFrameworkModifiedDomain(@UIEventTopic(FrameworkConstants.TOPIC_FRAMEWORK_DOMAIN_MODIFIED) Object o) {
|
||||
ProblemElement[] items = this.problemService.getAll(Expert.Type);
|
||||
if (items.length > 0)
|
||||
this.initPart(items[0]);
|
||||
DH.out("refresh", "subscribeFrameworkModifiedDomain");
|
||||
}
|
||||
}
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
|
||||
package flintstones.application.perspective.frameworkstructuring.ui.parts;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
||||
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||
import org.eclipse.e4.core.di.annotations.Optional;
|
||||
import org.eclipse.e4.core.services.nls.ILocaleChangeService;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
import org.eclipse.e4.ui.di.UIEventTopic;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import flintstones.application.constants.FrameworkConstants;
|
||||
import flintstones.application.perspective.frameworkstructuring.ui.messages.Messages;
|
||||
import flintstones.element.common.ui.providers.AssignmentsTableProvider;
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.FakeProblemElement;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.helper.debug.DH;
|
||||
import flintstones.helper.wtable.WTable;
|
||||
import flintstones.helper.wtable.WTableModel;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.valuation.service.IValuationService;
|
||||
|
||||
/**
|
||||
* The Class ElementsAssignmentStack.
|
||||
*/
|
||||
public class ViewElementsPart {
|
||||
|
||||
/** The problem service. */
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
/** The valuation service. */
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
/** The domain service. */
|
||||
@Inject
|
||||
IDomainService domainService;
|
||||
|
||||
/** The context. */
|
||||
@Inject
|
||||
IEclipseContext context;
|
||||
|
||||
/** The part. */
|
||||
@Inject
|
||||
MPart part;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private flintstones.entity.domain.messages.Messages domainMessages;
|
||||
|
||||
@Inject
|
||||
@Translation
|
||||
private flintstones.entity.problemelement.messages.Messages problemMessages;
|
||||
|
||||
/** The table. */
|
||||
private WTable wtable;
|
||||
|
||||
/** The table model. */
|
||||
private WTableModel tableModel;
|
||||
|
||||
/** The table provider. */
|
||||
private AssignmentsTableProvider provider;
|
||||
|
||||
/** The current problem element. */
|
||||
private ProblemElement currentProblemElement;
|
||||
|
||||
/** The base composite. */
|
||||
private Composite baseComposite;
|
||||
|
||||
/** is the table transposed */
|
||||
private boolean isTransposed = false;
|
||||
|
||||
/** The Constant SUB_ID_PROBLEM. */
|
||||
private static final String SUB_ID_PROBLEM = FrameworkConstants.TOPIC_FRAMEWORK_ALLTOPICS;
|
||||
|
||||
/** The Constant SUB_ID_SELECTION. */
|
||||
private static final String SUB_ID_SELECTION = FrameworkConstants.TOPIC_SELECTION_FRAMEWORK_PROBLEMELEMENT;
|
||||
|
||||
/** The Constant SUB_ID_TRANSPOSE. */
|
||||
private static final String SUB_ID_TRANSPOSE = "TOPIC/COMMAND/TRANSPOSE"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Inits the part.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init(Composite parent) {
|
||||
|
||||
this.baseComposite = parent;
|
||||
parent.getParent().setLayout(new FillLayout());
|
||||
|
||||
ProblemElement[] items = this.problemService.getAll(Expert.Type);
|
||||
|
||||
if (items.length > 0)
|
||||
this.initPart(items[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw table.
|
||||
*
|
||||
* @param parent the parent
|
||||
*/
|
||||
private void drawTable(Composite parent) {
|
||||
Composite cc = new Composite(parent, SWT.NONE);
|
||||
cc.setLayout(new FillLayout());
|
||||
this.wtable = new WTable(cc, SWT.V_SCROLL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh table.
|
||||
*/
|
||||
public void refreshTable() {
|
||||
if (this.currentProblemElement != null)
|
||||
this.initPart(this.currentProblemElement);
|
||||
baseComposite.layout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the part.
|
||||
*
|
||||
* @param pe Problem Element
|
||||
* Draw a table for the given Problem Element
|
||||
*/
|
||||
public void initPart(ProblemElement pe) {
|
||||
|
||||
if (this.wtable == null)
|
||||
this.drawTable(this.baseComposite);
|
||||
|
||||
this.currentProblemElement = pe;
|
||||
|
||||
// Part title
|
||||
this.drawPartTitle();
|
||||
|
||||
// Table
|
||||
this.provider = ContextInjectionFactory.make(AssignmentsTableProvider.class, this.context);
|
||||
this.provider.show(Domain.Fields.Domain.toString());
|
||||
this.provider.prepareTableContent(pe);
|
||||
|
||||
if (this.isTransposed)
|
||||
this.provider.transpose();
|
||||
|
||||
this.setTable();
|
||||
}
|
||||
|
||||
private void drawPartTitle() {
|
||||
ProblemElement pe = this.currentProblemElement;
|
||||
String template = this.messages.ElementsAssignmentStack_title_template;
|
||||
|
||||
String type = pe.getType();
|
||||
String label = ""; //$NON-NLS-1$
|
||||
|
||||
if (type.equals(Alternative.Type))
|
||||
label = this.problemMessages.ALTERNATIVE_ENTITY_NAME;
|
||||
else if (type.equals(Criterion.Type))
|
||||
label = this.problemMessages.CRITERION_ENTITY_NAME;
|
||||
else if (type.equals(Expert.Type))
|
||||
label = this.problemMessages.EXPERT_ENTITY_NAME;
|
||||
|
||||
String message = MessageFormat.format(template, label, pe.getCanonicalName());
|
||||
this.part.setLabel(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the table.
|
||||
*/
|
||||
private void setTable() {
|
||||
|
||||
// Clear last table listener if it exists
|
||||
if (this.tableModel != null)
|
||||
this.tableModel.clearListeners();
|
||||
|
||||
this.tableModel = new WTableModel(this.wtable);
|
||||
|
||||
// Cabeceras
|
||||
this.tableModel.setHorizontalHeaders(this.provider.getTableHeaderH());
|
||||
this.tableModel.setVerticalHeaders(this.provider.getTableHeaderV());
|
||||
|
||||
// Contenido, PH, Abbr
|
||||
this.tableModel.addContent(this.provider.getTableValuations());
|
||||
|
||||
this.wtable.setModel(this.tableModel);
|
||||
this.tableModel.init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subscribe selection.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeSelectionAlt(@UIEventTopic(ViewElementsPart.SUB_ID_SELECTION) ProblemElement pe) {
|
||||
|
||||
if(pe != null && !(pe instanceof FakeProblemElement)) {
|
||||
this.initPart(pe);
|
||||
this.refreshTable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe problem.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeProblem(@UIEventTopic(ViewElementsPart.SUB_ID_PROBLEM) Map<String, String> event) {
|
||||
this.refreshTable();
|
||||
|
||||
DH.out("refresh", "refreshTable");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe transpose.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeTranspose(@UIEventTopic(ViewElementsPart.SUB_ID_TRANSPOSE) Map<String, Object> event) {
|
||||
DH.out("refresh", "subscribeTranspose");
|
||||
|
||||
if (this.currentProblemElement != null) {
|
||||
this.provider.transpose();
|
||||
this.setTable();
|
||||
this.isTransposed = !this.isTransposed;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
@Optional
|
||||
private void getNotified(@UIEventTopic(ILocaleChangeService.LOCALE_CHANGE) Locale s) {
|
||||
DH.out("refresh", "getNotified");
|
||||
|
||||
this.drawPartTitle();
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeFrameworkstructuring(@UIEventTopic(FrameworkConstants.TOPIC_VALUATION_ASSIGNED) Object o) {
|
||||
ProblemElement[] items = this.problemService.getAll(Expert.Type);
|
||||
if (items.length > 0)
|
||||
this.initPart(items[0]);
|
||||
DH.out("refresh", "subscribeFrameworkstructuring");
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeFramework(@UIEventTopic(FrameworkConstants.TOPIC_FRAMEWORK_DOMAIN_CREATED) Object o) {
|
||||
ProblemElement[] items = this.problemService.getAll(Expert.Type);
|
||||
|
||||
if (items.length > 0)
|
||||
this.initPart(items[0]);
|
||||
DH.out("refresh", "subscribeFramework");
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Optional
|
||||
private void subscribeFramework2(@UIEventTopic(FrameworkConstants.TOPIC_FRAMEWORK_PROBLEMELEMENT_ALLTOPICS) Object o) {
|
||||
ProblemElement[] items = this.problemService.getAll(Expert.Type);
|
||||
|
||||
if (items.length > 0)
|
||||
this.initPart(items[0]);
|
||||
DH.out("refresh", "subscribeFramework");
|
||||
}
|
||||
}
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
package flintstones.application.perspective.frameworkstructuring.ui.parts.rename;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import flintstones.entity.problemelement.entities.FakeProblemElement;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
|
||||
public class AssignationItem {
|
||||
|
||||
// Current item
|
||||
ProblemElement element1;
|
||||
ProblemElement element2 = null;
|
||||
ProblemElement element3 = null;
|
||||
|
||||
// Relatives
|
||||
AssignationItem parent = null;
|
||||
List<AssignationItem> children = new LinkedList<>();
|
||||
|
||||
// Data
|
||||
String assignedDomainId = "";
|
||||
boolean isEnabled = true;
|
||||
|
||||
|
||||
|
||||
public AssignationItem(FakeProblemElement rootItem, ProblemElement[] elements1, ProblemElement[] elements2,
|
||||
ProblemElement[] elements3) {
|
||||
|
||||
element1 = rootItem;
|
||||
|
||||
for (ProblemElement element1 : elements1) {
|
||||
children.add(new AssignationItem(element1, elements2, elements3));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private AssignationItem(ProblemElement cElement1, ProblemElement[] elements2, ProblemElement[] elements3) {
|
||||
|
||||
element1 = cElement1;
|
||||
|
||||
if (cElement1.hasChildren()) {
|
||||
ProblemElement[] childList = element1.getChildren();
|
||||
for (ProblemElement child : childList) {
|
||||
AssignationItem agg = new AssignationItem(child, elements2, elements3);
|
||||
agg.setParent(this);
|
||||
children.add(agg);
|
||||
}
|
||||
} else {
|
||||
for (ProblemElement cElement2 : elements2) {
|
||||
AssignationItem agg = new AssignationItem(cElement1, cElement2, elements3);
|
||||
agg.setParent(this);
|
||||
children.add(agg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private AssignationItem(ProblemElement cElement1, ProblemElement cElement2, ProblemElement[] elements3) {
|
||||
|
||||
element1 = cElement1;
|
||||
element2 = cElement2;
|
||||
|
||||
if (cElement2.hasChildren()) {
|
||||
ProblemElement[] childList = element2.getChildren();
|
||||
for (ProblemElement child : childList) {
|
||||
AssignationItem agg = new AssignationItem(cElement1, child, elements3);
|
||||
agg.setParent(this);
|
||||
children.add(agg);
|
||||
}
|
||||
} else {
|
||||
for (ProblemElement criterion : elements3) {
|
||||
AssignationItem agg = new AssignationItem(cElement1, cElement2, criterion);
|
||||
agg.setParent(this);
|
||||
children.add(agg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private AssignationItem(ProblemElement cElement1, ProblemElement cElement2, ProblemElement cElement3) {
|
||||
|
||||
element1 = cElement1;
|
||||
element2 = cElement2;
|
||||
element3 = cElement3;
|
||||
|
||||
if (element3.hasChildren()) {
|
||||
ProblemElement[] criterions = cElement3.getChildren();
|
||||
for (ProblemElement c : criterions) {
|
||||
AssignationItem agg = new AssignationItem(cElement1, cElement2, c);
|
||||
agg.setParent(this);
|
||||
children.add(agg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
String a = element1 != null ? element1.getName() : "1X";
|
||||
String e = element2 != null ? element2.getName() : "2X";
|
||||
String c = element3 != null ? element3.getName() : "3X";
|
||||
|
||||
return a + " : " + e + " : " + c;
|
||||
}
|
||||
|
||||
public ProblemElement getFinalItem() {
|
||||
if (element3 != null)
|
||||
return element3;
|
||||
if (element2 != null)
|
||||
return element2;
|
||||
return element1;
|
||||
}
|
||||
|
||||
public void setParent(AssignationItem item) {
|
||||
parent = item;
|
||||
}
|
||||
|
||||
public AssignationItem getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public boolean hasChildren() {
|
||||
return children.size() != 0;
|
||||
}
|
||||
|
||||
public AssignationItem[] getChildren() {
|
||||
return children.toArray(new AssignationItem[0]);
|
||||
}
|
||||
|
||||
public void setChildren(List<AssignationItem> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
//
|
||||
// public ProblemElement getAlternative() {
|
||||
// return element1;
|
||||
// }
|
||||
//
|
||||
// public void setAlternative(Alternative item, boolean cascade) {
|
||||
// this.element1 = item;
|
||||
// if(cascade)
|
||||
// children.stream().forEach(k -> k.setAlternative(item, cascade));
|
||||
// }
|
||||
//
|
||||
public ProblemElement getElement2() {
|
||||
return element2;
|
||||
}
|
||||
|
||||
public ProblemElement getElement3() {
|
||||
return element3;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean x) {
|
||||
isEnabled = x;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
public String setDomainId() {
|
||||
return assignedDomainId;
|
||||
}
|
||||
|
||||
// public void setOperatorId(String op) {
|
||||
// this.assignedDomainId = op;
|
||||
// }
|
||||
|
||||
public void setDomainId(String op, boolean cascade) {
|
||||
|
||||
// If the aggregation item is leaf, do assign operator
|
||||
if (children.size() != 0)
|
||||
return;
|
||||
|
||||
this.assignedDomainId = op;
|
||||
if (cascade)
|
||||
children.stream().forEach(k -> k.setDomainId(op, true));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user