public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
.DS_Store
/.metadata/
# https://stackoverflow.com/questions/1470572/ignoring-any-bin-directory-on-a-git-project
*.class
bin/
target/
# Ignore Maven Output
target/
# Ignore Visual Studio Code
.vs/
+7
View File
@@ -0,0 +1,7 @@
<extensions>
<extension>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-pomless</artifactId>
<version>2.0.0</version>
</extension>
</extensions>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
+7
View File
@@ -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
View File
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
+29
View File
@@ -0,0 +1,29 @@
FROM maven:3.8.6-eclipse-temurin-11
# GTK3 + X11 para poder ejecutar la app dentro del contenedor
RUN apt-get update && apt-get install -y \
libgtk-3-0 \
libwebkit2gtk-4.0-37 \
libcanberra-gtk-module \
libcanberra-gtk3-module \
xvfb \
x11vnc \
x11-utils \
fonts-dejavu \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /project
# Pre-cacheamos dependencias de Maven (se ejecuta solo si pom.xml cambia)
COPY pom.xml .
COPY .mvn .mvn
COPY releng/flintstones.application.configuration/pom.xml releng/flintstones.application.configuration/pom.xml
RUN mvn dependency:go-offline -N -f releng/flintstones.application.configuration/pom.xml 2>/dev/null || true
# Copiamos el resto del proyecto
COPY . .
# Build completo
RUN mvn clean install -Dmaven.test.skip=true
CMD ["bash"]
+27
View File
@@ -0,0 +1,27 @@
FROM --platform=linux/amd64 eclipse-temurin:11-jre-focal
RUN apt-get update && apt-get install -y \
libgtk-3-0 \
libwebkit2gtk-4.0-37 \
libcanberra-gtk3-module \
libglib2.0-0 \
tigervnc-standalone-server \
tigervnc-common \
novnc \
websockify \
openbox \
x11-xkb-utils \
xkb-data \
fonts-dejavu \
fonts-liberation \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 6080
ENV DISPLAY=:1
ENV LANG=es_ES.UTF-8
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
+409
View File
@@ -0,0 +1,409 @@
# Flintstones
Plataforma de escritorio para **Toma de Decisiones Multi-Criterio (MCDM/MCDA)** desarrollada por el grupo de investigación [Sinbad2](http://sinbad2.ujaen.es/) de la Universidad de Jaén.
Flintstones permite definir un problema de decisión (alternativas, criterios, expertos, dominios) y resolverlo con una amplia colección de métodos de ayuda a la decisión, desde AHP clásico hasta modelos lingüísticos avanzados basados en conjuntos difusos y 2-tuplas.
---
## Tabla de contenidos
- [Requisitos](#requisitos)
- [Compilar](#compilar)
- [Ejecutar](#ejecutar)
- [Métodos disponibles](#métodos-disponibles)
- [Tipos de información](#tipos-de-información)
- [Operadores](#operadores)
- [Arquitectura del proyecto](#arquitectura-del-proyecto)
- [Estructura de directorios](#estructura-de-directorios)
- [Flujo de trabajo en la aplicación](#flujo-de-trabajo-en-la-aplicación)
- [Problemas conocidos resueltos](#problemas-conocidos-resueltos)
---
## Requisitos
| Herramienta | Versión mínima | Notas |
|---|---|---|
| Docker | 20+ | Para compilar sin instalar nada más |
| Java | 11 | Solo para ejecutar el producto compilado |
| Maven | 3.8+ | Solo si compilas fuera de Docker |
> **Sin Docker:** necesitas JDK 11 y Maven 3.8+.
> **Con Docker:** solo Docker. El contenedor lleva Maven 3.8.6 y JDK 11.
---
## Compilar
### Con Docker (recomendado)
```bash
./build.sh
```
O directamente:
```bash
docker compose run --rm build
```
La primera vez descarga dependencias de Eclipse (~1-2 GB). Las siguientes compilaciones usan caché y son mucho más rápidas.
Los productos quedan en:
```
releng/flintstones.application.product/target/products/
RCP product-linux.gtk.x86_64.zip
RCP product-macosx.cocoa.x86_64.zip
RCP product-win32.win32.x86_64.zip
```
### Sin Docker
```bash
mvn clean install -Dmaven.test.skip=true
```
---
## Ejecutar
### macOS
```bash
cd releng/flintstones.application.product/target/products/
unzip "RCP product-macosx.cocoa.x86_64.zip"
open Eclipse.app
```
> El ejecutable se llama `Eclipse.app` por herencia del launcher de Eclipse RCP.
> En Apple Silicon (M1/M2/M3) funciona vía Rosetta 2 (arquitectura x86_64).
### Linux
```bash
cd releng/flintstones.application.product/target/products/
unzip "RCP product-linux.gtk.x86_64.zip"
./"RCP product"/linux/gtk/x86_64/flinstones
```
Requiere GTK3:
```bash
sudo apt install libgtk-3-0 # Debian/Ubuntu
```
### Linux con VNC (desde Docker)
Levanta el contenedor con display virtual accesible en `localhost:5900`:
```bash
docker compose run --rm run-vnc
```
Conéctate con cualquier cliente VNC (RealVNC, TigerVNC, etc.) a `localhost:5900`.
### Windows
Descomprime `RCP product-win32.win32.x86_64.zip` y ejecuta `flinstones.exe`.
---
## Métodos disponibles
### Métodos clásicos / Ranking
| Método | Bundle | Descripción |
|---|---|---|
| **AHP** | `flintstones.method.ahp` | Analytic Hierarchy Process. Descomposición jerárquica de un problema con comparaciones por pares. |
| **AHP-Sort** | `flintstones.method.ahp.sort` | Variante de clasificación (sorting) sobre AHP. |
| **AHP-SortII** | `flintstones.method.ahp.sortii` | Segunda versión de AHP-Sort con agregación grupal mejorada. |
| **AHP-Sort Fuzzy** | `flintstones.method.ahp.sort.fuzzy` | AHP-Sort con información difusa. |
| **Numeric TOPSIS** | `flintstones.method.decision.topsis.numeric` | TOPSIS clásico (Hwang & Yoon, 1981). Alternativa más próxima a la solución ideal positiva y más alejada de la negativa. |
| **VIKOR** | `flintstones.method.vikor` | Método de compromiso para criterios conflictivos (Opricovic). |
| **Fuzzy VIKOR** | `flintstones.method.vikorFuzzy` | VIKOR con pesos y criterios como números difusos triangulares. |
| **ELECTRE** | `flintstones.method.electre` | Método de superación (outranking) con relaciones de concordancia y discordancia. |
| **PROMETHEE** | `flintstones.method.promethee` | Outranking basado en flujos netos de preferencia. |
| **FlowSort** | `flintstones.method.flowsort` | Extensión de PROMETHEE para problemas de clasificación. |
| **TODIM** | `flintstones.method.todim` | Basado en la Teoría Prospectiva, modela el comportamiento del decisor ante ganancias y pérdidas. |
| **MMOORA** | `flintstones.method.mmoora` | Multi-MOORA: combina ratio system, reference point y full multiplicative form. |
| **Fuzzy MMOORA** | `flintstones.method.mmooraFuzzy` | MMOORA con información difusa. |
| **WASPAS** | `flintstones.method.waspas` | Weighted Aggregated Sum Product ASsessment: combinación de WSM y WPM. |
| **Fuzzy WASPAS** | `flintstones.method.waspasFuzzy` | WASPAS con números difusos. |
| **dEvaluation** | `flintstones.method.dEvaluation` | *(en desarrollo)* |
### Métodos lingüísticos y difusos
| Método | Bundle | Descripción |
|---|---|---|
| **2-Tuple** | `flintstones.method.twoTuple` | Modelo 2-tupla lingüística (Herrera & Martínez, 2000). Elimina pérdida de información en la fusión lingüística. |
| **Hesitant Linguistic** | `flintstones.method.linguistic.hesitant` | MCDM con expresiones lingüísticas comparativas y 2-tuplas para retranslación. |
| **HFLTS** | `flintstones.method.linguistic.hflts` | Hesitant Fuzzy Linguistic Term Sets. Para expertos que dudan entre varios términos lingüísticos. |
| **ELICIT** | `flintstones.method.linguistic.elicit` | Extended Comparative Linguistic Expressions with Symbolic Translation. Modelo de representación lingüística más rico que la 2-tupla. |
| **Linguistic TOPSIS** | `flintstones.method.linguistic.topsis` | TOPSIS con modelo 2-tupla y función de distancia mejorada. |
| **Heterogeneous Fusion** | `flintstones.method.linguistic.heterogeneous.fusion` | Fusión de información heterogénea (numérica, lingüística, intervalar) con 2-tuplas. |
| **Unbalanced Linguistic** | `flintstones.method.linguistic.unbalanced` | Conjuntos de términos lingüísticos no uniformes ni simétricos. |
| **Multigranular LH** | `flintstones.method.linguistic.multigranular.lh` | Jerarquías lingüísticas para información multigranular. |
| **Multigranular ELH** | `flintstones.method.linguistic.multigranular.elh` | Jerarquía lingüística extendida (ELH) para mayor flexibilidad de escalas. |
| **Multigranular Fusion** | `flintstones.method.linguistic.multigranular.fusion` | Fusión multigranular sin restricciones en las escalas, con principio de extensión. |
| **Fuzzy TOPSIS** | `flintstones.method.topsisFuzzy` | TOPSIS con valoraciones difusas. |
| **Numeric Common Aggregation** | `flintstones.method.numeric.common.aggregation` | Agregación con información numérica. |
---
## Tipos de información
### Dominios de valoración
| Tipo | Bundle | Descripción |
|---|---|---|
| **Fuzzy Set** | `flintstones.domain.fuzzyset` | Conjuntos difusos (números difusos triangulares). |
| **Unbalanced Fuzzy Set** | `flintstones.domain.fuzzyset.unbalanced` | Conjuntos difusos con distribución no uniforme. |
| **Integer Numeric** | `flintstones.domain.numeric.integer` | Dominio numérico entero. |
| **Real Numeric** | `flintstones.domain.numeric.real` | Dominio numérico real. |
### Tipos de valoración (Valuations)
| Tipo | Bundle |
|---|---|
| Lingüística (2-tupla) | `flintstones.valuation.linguistic` |
| ELICIT | `flintstones.valuation.elicit` |
| Hesitant (HFLTS) | `flintstones.valuation.hesitant` |
| Unbalanced | `flintstones.valuation.unbalanced` |
| 2-Tupla | `flintstones.valuation.twoTuple` |
| Proporcional 2-Tupla | `flintstones.valuation.proportionaltwotuple` |
| AHP | `flintstones.valuation.ahp` |
| Numérica entera | `flintstones.valuation.numeric.integer` |
| Numérica entera (intervalo) | `flintstones.valuation.numeric.integer.interval` |
| Numérica real | `flintstones.valuation.numeric.real` |
| Numérica real (intervalo) | `flintstones.valuation.numeric.real.interval` |
| Unificada | `flintstones.valuation.unifiedValuation` |
| Difusa | `flintstones.valuation.fuzzy` |
---
## Operadores
### Agregación
| Operador | Bundle |
|---|---|
| Media aritmética | `flintstones.operator.aggregation.arithmeticmean` |
| Media geométrica | `flintstones.operator.aggregation.geometricMean` |
| Media armónica | `flintstones.operator.aggregation.harmonicmean` |
| OWA (Ordered Weighted Averaging) | `flintstones.operator.aggregation.owa` |
| Mínimo | `flintstones.operator.aggregation.min` |
| Máximo | `flintstones.operator.aggregation.max` |
| MinMax | `flintstones.operator.aggregation.minmax` |
| Mediana | `flintstones.operator.aggregation.median` |
| Integral de Choquet | `flintstones.operator.aggregation.choquetIntegral` |
| Media de Bonferroni | `flintstones.operator.aggregation.bonferroniMean` |
Los pesos para OWA se calculan con cuantificadores de Yager (`flintstones.quantifiers.yager`).
### Normalización (métodos numéricos)
| Operador | Bundle |
|---|---|
| Ideal | `flintstones.operator.normalization.numeric.ideal` |
| Distribuida | `flintstones.operator.normalization.numeric.distributed` |
### Unificación (métodos lingüísticos)
| Operador | Bundle |
|---|---|
| 2-Tupla | `flintstones.operator.unification.twotuple` |
| ELICIT | `flintstones.operator.unification.elicit` |
| Difusa | `flintstones.operator.unification.fuzzy` |
---
## Arquitectura del proyecto
Flintstones es una aplicación **Eclipse 4 RCP** (Rich Client Platform) basada en OSGi. Cada funcionalidad se encapsula como un bundle independiente con dependencias declaradas en `META-INF/MANIFEST.MF`.
```
┌─────────────────────────────────────────────────────┐
│ Eclipse E4 RCP Shell │
│ (workbench, perspectives, parts, DI) │
├──────────────┬──────────────┬───────────────────────┤
│ application │ framework │ perspective.* │
│ (UI global) │ (UI MCDM) │ (panels por etapa) │
├──────────────┴──────────────┴───────────────────────┤
│ method.* (implementación métodos) │
├─────────────────────────────────────────────────────┤
│ entity.* │ valuation.* │ domain.* │ operator.* │
│ (modelo) │ (valoraciones)│ (dominios)│ (operadores│
├───────────┴───────────────┴────────────┴────────────┤
│ model.*.service / model.*.provider │
│ (capa de servicios OSGi, acceso a datos) │
├─────────────────────────────────────────────────────┤
│ helper.* (utilidades: I/O, datos, validación) │
└─────────────────────────────────────────────────────┘
```
### Patrón service / provider
Cada modelo de datos tiene dos bundles:
- `flintstones.model.X.service` — interfaz OSGi (contrato)
- `flintstones.model.X.provider` — implementación concreta
Los bundles se conectan vía inyección de dependencias de Eclipse E4 (`@Inject`).
### Motor R
El bundle `flintstones.engine.R` integra el motor estadístico R para cálculos avanzados.
---
## Estructura de directorios
```
flintstones-develop/
├── bundles/ # Todos los plugins OSGi (~250 bundles)
│ ├── flintstones.application/ # Bundle principal (E4 app model)
│ ├── flintstones.application.*/ # UI de la aplicación
│ ├── flintstones.domain.*/ # Tipos de dominio de valoración
│ ├── flintstones.entity.*/ # Entidades del modelo de dominio
│ ├── flintstones.method.*/ # Implementaciones de métodos MCDM
│ ├── flintstones.model.*.service/ # Interfaces de servicio OSGi
│ ├── flintstones.model.*.provider/ # Implementaciones de servicio
│ ├── flintstones.operator.*/ # Operadores de agregación/unificación
│ ├── flintstones.valuation.*/ # Tipos de valoración
│ ├── flintstones.helper.*/ # Utilidades (I/O, datos, UI, validación)
│ ├── flintstones.quantifiers.*/ # Cuantificadores lingüísticos
│ ├── flintstones.engine.R/ # Integración con el motor R
│ ├── flintstones.clustering.*/ # Clustering aglomerativo
│ ├── flintstones.theme/ # Tema visual
│ ├── org.apache.commons.math3/ # Dependencia: Apache Commons Math
│ ├── org.jfree.chart.jfreechart/ # Dependencia: JFreeChart
│ ├── de.jaret.util.swt/ # Dependencia: Jaret SWT utils
│ ├── de.kupzog.ktable/ # Dependencia: KTable
│ └── org.eclipse.nebula.*/ # Dependencia: Eclipse Nebula widgets
├── features/ # Features Eclipse (agrupaciones de bundles)
│ ├── flintstones.feature.application/
│ ├── flintstones.feature.domain/
│ ├── flintstones.feature.element/
│ ├── flintstones.feature.engine/
│ ├── flintstones.feature.entity/
│ ├── flintstones.feature.helper/
│ ├── flintstones.feature.libraries/
│ ├── flintstones.feature.method/
│ ├── flintstones.feature.model/
│ ├── flintstones.feature.operator/
│ ├── flintstones.feature.quantifiers/
│ ├── flintstones.feature.theme/
│ └── flintstones.feature.valuation/
├── releng/ # Release engineering
│ ├── flintstones.application.configuration/ # POM raíz con config de Tycho
│ ├── flintstones.application.product/ # Definición del producto (.product)
│ └── flintstones.application.update/ # Update site
├── Dockerfile # Imagen Docker para compilar y ejecutar
├── docker-compose.yml # Servicios: build, run (Xvfb), run-vnc
├── build.sh # Script de compilación
└── pom.xml # POM raíz Maven
```
---
## Flujo de trabajo en la aplicación
La aplicación guía al usuario a través de **perspectivas** secuenciales:
```
1. Framework
└─ Definir: alternativas, criterios (con pesos y dominios), expertos
2. Framework Structuring
└─ Organizar la estructura jerárquica del problema
3. Gathering
└─ Recoger las valoraciones de cada experto sobre cada alternativa/criterio
4. Method Selection
└─ Elegir el método MCDM a aplicar y configurarlo
5. Execution / Results
└─ Ejecutar el método y visualizar el ranking de alternativas
6. Sensitive Analysis
└─ Analizar la robustez de los resultados ante variaciones en los pesos
```
Los ficheros de problema se guardan/cargan desde **File → Save / Open**.
El formato de archivo es propio de Flintstones (XML interno).
---
## Problemas conocidos resueltos
Los siguientes problemas estaban presentes en el repositorio y han sido corregidos:
### 1. Bundles inexistentes en `feature.xml`
`flintstones.feature.method/feature.xml` referenciaba tres bundles que ya no existen en el código:
```
flintstones.method.linguistic.elicit.topsis
flintstones.method.linguistic.elicit.topsis.phase.experts
flintstones.method.linguistic.elicit.topsis.phase.experts.ui
```
**Fix:** eliminados del `feature.xml`.
### 2. Entradas duplicadas en `feature.xml`
El mismo `feature.xml` contenía dos veces las entradas de `flintstones.method.linguistic.topsis.*`.
**Fix:** eliminada la segunda ocurrencia.
### 3. URLs HTTP obsoletas en el POM
El POM de configuración usaba URLs `http://` que ya no funcionan:
| Antes | Después |
|---|---|
| `http://download.eclipse.org/releases/photon` | `https://download.eclipse.org/releases/2018-09` |
| `http://central.maven.org/maven2/` | `https://repo1.maven.org/maven2/` |
El repositorio de Eclipse Photon (2018) se actualizó a **2018-09** porque Photon no incluía el perfil JRE para JavaSE-11 en su repositorio p2 y los bundles del proyecto lo requieren.
### 4. Plataformas de 32 bits incompatibles con JavaSE-11
Los targets `linux/gtk/x86` y `win32/win32/x86` no pueden resolver `osgi.ee=JavaSE(version=11)` porque no hay JDK 11 de 32 bits disponible.
**Fix:** eliminados. Solo se compila para x86_64 (Linux, Windows, macOS).
### 5. Tycho no encontraba el perfil JavaSE-11
**Fix:** añadidas al `target-platform-configuration`:
```xml
<executionEnvironment>JavaSE-11</executionEnvironment>
<breeAsFilter>false</breeAsFilter>
```
### Bundles huérfanos (pendientes de integrar)
Existen en el código pero no están incluidos en ninguna feature (no se empaquetan en el producto):
| Bundle | Estado |
|---|---|
| `flintstones.operator.aggregation.bonferroniMean` | En disco, no en `pom.xml` ni en features |
| `flintstones.operator.unification.fuzzy` | En disco, no en `pom.xml` ni en features |
| `flintstones.method.dEvaluation` (+ sub-bundles) | En `pom.xml`, no en features |
| `flintstones.valuation.fuzzy` | En `pom.xml`, no en features |
| `flintstones.valuation.proportionaltwotuple` | En `pom.xml`, no en features |
| `flintstones.clustering.agglomerative` | En `pom.xml`, no en features |
---
## Tecnologías
| Tecnología | Uso |
|---|---|
| **Java 11** | Lenguaje principal |
| **OSGi / Equinox** | Framework de componentes |
| **Eclipse E4 RCP** | Framework de aplicación de escritorio |
| **Eclipse SWT + JFace** | Widgets y UI |
| **Maven Tycho 2.0.0** | Sistema de build para proyectos Eclipse |
| **EMF** | Eclipse Modeling Framework (modelos de datos) |
| **Apache Commons Math 3** | Cálculos matemáticos y estadísticos |
| **JFreeChart** | Gráficas y visualización |
| **R Engine** | Cálculos estadísticos avanzados |
| **Eclipse Nebula** | Widgets SWT adicionales |
| **Docker** | Entorno de build reproducible |
+10
View File
@@ -0,0 +1,10 @@
:: Hacer los SET
:: Actualizar POM
:: Build
mvn clean install
pause
pause
pause
Executable
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
# Compila Flintstones en Docker (no hace falta tener Maven ni Java 11 local)
set -e
PRODUCTS_DIR="releng/flintstones.application.product/target/products"
echo "==> Compilando Flintstones con Maven 3.8 + JDK 11 en Docker..."
docker compose run --rm build
echo ""
echo "==> Build completado. Productos:"
ls "$PRODUCTS_DIR/"*.zip 2>/dev/null | while read f; do echo " $f"; done
echo ""
echo "==> Para ejecutar en macOS:"
echo " cd '$PRODUCTS_DIR'"
MACOS_ZIP=$(ls "$PRODUCTS_DIR"/*macosx*.zip 2>/dev/null | head -1)
if [ -n "$MACOS_ZIP" ]; then
echo " unzip -o '$MACOS_ZIP'"
echo " open Eclipse.app"
echo " (o doble clic en Eclipse.app desde el Finder)"
fi
echo ""
echo "==> Para ejecutar en Linux con VNC (puerto 5900):"
echo " docker compose run --rm run-vnc"
echo " Conectar con cualquier cliente VNC a localhost:5900"
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
+7
View File
@@ -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>
@@ -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>de.jaret.util.swt</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Swt</name>
</project>
+45
View File
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>de.jaret.util.swt</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>1779484362508</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>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -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
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Swt
Bundle-SymbolicName: de.jaret.util.swt
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: de.jaret.util.swt
Require-Bundle: org.eclipse.swt
Export-Package: de.jaret.util.swt
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -0,0 +1,488 @@
/*
* File: SwtGraphicsHelper.java
* Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de)
* A commercial license is available, see http://www.jaret.de.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*/
package de.jaret.util.swt;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Transform;
/**
* A simple class containing several static methods for convenient painting with a SWT gc.
*
* @author Peter Kliem
* @version $Id: SwtGraphicsHelper.java 726 2008-03-18 21:06:14Z kliem $
*/
public class SwtGraphicsHelper {
/**
* Draw a string centered between x,y at top y.
* @param gc gc
* @param string string
* @param left left bound
* @param right right bound
* @param y top y
*/
public static void drawStringCentered(GC gc, String string, int left, int right, int y) {
Point extent = gc.textExtent(string);
int width = right - left;
int xx = (int) ((width - extent.x) / 2);
gc.drawString(string, left+xx, y);
}
public static void drawStringCenteredMidX(GC gc, String string, int midx, int y) {
Point extent = gc.textExtent(string);
int xx = (int) (midx - (extent.x / 2));
gc.drawString(string, xx, y);
}
public static void drawStringCenteredVCenter(GC gc, String string, int left, int right, int yCenter) {
Point extent = gc.textExtent(string);
// int descent = graphics.getFontMetrics().getDescent();
int descent = 0;
int width = right - left;
int xx = (int) ((width - extent.x) / 2);
int y = yCenter - (int) (extent.y / 2 - descent);
gc.drawString(string, left + xx, y);
}
public static void drawStringRightAlignedVCenter(GC gc, String string, int x, int y) {
Point extent = gc.textExtent(string);
int xx = (int) (x - extent.x);
int yy = (int) (y - (extent.y / 2));
gc.drawString(string, xx, yy);
}
public static void drawStringLeftAlignedVCenter(GC gc, String string, int x, int y) {
Point extent = gc.textExtent(string);
int xx = x;
int yy = (int) (y - (extent.y / 2));
gc.drawString(string, xx, yy);
}
public static void drawStringCentered(GC gc, String string, int xCenter, int yBase) {
Point extent = gc.textExtent(string);
int xx = xCenter - (int) ((extent.x) / 2);
gc.drawText(string, xx, yBase - extent.y, true);
}
public static void drawStringCenteredAroundPoint(GC gc, String string, int xCenter, int yCenter) {
Point extent = gc.textExtent(string);
int xx = xCenter - (int) ((extent.x) / 2);
int yy = yCenter - (int) ((extent.y) / 2);
gc.drawText(string, xx, yy, true);
}
/**
* Draw the string centered in the given rectangle (specified by plain values)
*
* @param gc
* @param string
* @param x
* @param y
* @param width
* @param height
*/
public static void drawStringCentered(GC gc, String string, int x, int y, int width, int height) {
Point extent = gc.textExtent(string);
int xx = x + (width - extent.x) / 2;
int yy = y + (height - extent.y) / 2;
gc.drawText(string, xx, yy, true);
}
/**
* Draw String centered in the given rectangle.
*
* @param gc
* @param string
* @param rect
*/
public static void drawStringCentered(GC gc, String string, Rectangle rect) {
drawStringCentered(gc, string, rect.x, rect.y, rect.width, rect.height);
}
public static int getStringDrawingWidth(GC gc, String string) {
return gc.textExtent(string).x;
}
public static int getStringDrawingHeight(GC gc, String string) {
return gc.textExtent(string).y;
}
/**
* Draws a String right aligned with the y coordinate denoting the top of the string.
* @param gc GC
* @param string string to draw
* @param x right x position
* @param yTop top y position
*/
public static void drawStringRightAlignedVTop(GC gc, String string, int x, int yTop) {
Point extent = gc.textExtent(string);
int xx = (int) (x - extent.x);
gc.drawText(string, xx, yTop, true);
}
public static void drawArrowLine(GC gc, int x1, int y1, int x2, int y2, int dist, int height, boolean arrowLeft,
boolean arrowRight) {
int off = height;
gc.drawLine(x1 + off + 1, y1, x2 - off - 1, y2);
if (arrowLeft) {
gc.drawLine(x1, y1, x1 + dist, y1 - off);
gc.drawLine(x1, y1, x1 + dist, y1 + off);
gc.drawLine(x1 + dist, y1 - off, x1 + dist, y1 + off);
}
if (arrowRight) {
gc.drawLine(x2, y2, x2 - dist, y2 - off);
gc.drawLine(x2, y2, x2 - dist, y2 + off);
gc.drawLine(x2 - dist, y2 - off, x2 - dist, y2 + off);
}
}
public static void drawArrowLineVertical(GC gc, int x1, int y1, int x2, int y2, int dist, int height,
boolean arrowUp, boolean arrowDown) {
int off = height;
gc.drawLine(x1, y1 + off + 1, x2, y2 - off - 1);
if (arrowUp) {
gc.drawLine(x1, y1, x1 - off, y1 + dist);
gc.drawLine(x1, y1, x1 + off, y1 + dist);
gc.drawLine(x1 - off, y1 + dist, x1 + off, y1 + dist);
}
if (arrowDown) {
gc.drawLine(x2, y2, x2 - off, y2 - dist);
gc.drawLine(x2, y2, x2 + off, y2 - dist);
gc.drawLine(x2 - off, y2 - dist, x2 + off, y2 - dist);
}
}
/**
* Draw a string vertical centered beetween upper and lower y left aligned to x.
*
* @param gc GC
* @param label label to draw
* @param x left x
* @param upperY upper y bound
* @param lowerY lower y bound
*/
public static void drawStringVCentered(GC gc, String label, int x, int upperY, int lowerY) {
Point extent = gc.textExtent(label);
int yy = (int) upperY + (lowerY - upperY - extent.y) / 2;
gc.drawText(label, x, yy, true);
}
/**
* Draw a String vertical. This method might be quite costly since it uses an image to buffer.
*
* @param gc gc
* @param string strin gto to draw
* @param x upper left x
* @param y upper left y
*/
public static void drawStringVertical(GC gc, String string, int x, int y) {
Point extent = gc.textExtent(string);
Image img = new Image(gc.getDevice(), extent.x, extent.y);
GC imageGC = new GC(img);
imageGC.drawString(string, 0, 0);
imageGC.dispose();
Image vertImg = new Image(gc.getDevice(), extent.y, extent.x);
ImageData iData = img.getImageData();
ImageData destIData = vertImg.getImageData();
for (int xx = 0; xx < iData.width; xx++) {
for (int yy = 0; yy < iData.height; yy++) {
destIData.setPixel(yy, iData.width-xx-1, iData.getPixel(xx, yy));
}
}
img.dispose();
Image destImg = new Image(gc.getDevice(), destIData);
gc.drawImage(destImg, x, y);
vertImg.dispose();
destImg.dispose();
}
/**
* Create an image with a drop shadow. This method is (c) 2007 Nicholas Rajendram, IBM Canada, see
* http://www.eclipse.org/articles/article.php?file=Article-SimpleImageEffectsForSWT/index.html.
*
* @param originalImageData The original image. Transparency information will be ignored.
* @param color The color of the drop shadow
* @param radius The radius of the drop shadow in pixels
* @param highlightRadius The radius of the highlight area
* @param opacity The opacity of the drop shadow
* @return The drop shadowed image. This image data will be larger than the original. The same image data will be
* returned if the shadow radius is 0, or null if an error occured.
*/
public static ImageData dropShadow(ImageData originalImageData, Color color, int radius, int highlightRadius,
int opacity) {
/*
* This method will create a drop shadowto the bottom-right of an existing image. This drop shadow is created by
* creating an altered one-sided glow, and shifting its position around the image. See the Glow class for more
* details of how the glow is calculated.
*/
if (originalImageData == null)
return null;
if (color == null)
return null;
if (radius == 0)
return originalImageData;
int shift = (int) (radius * 1.5); // distance to shift "glow" from image
// the percent increase in color intensity in the highlight radius
double highlightRadiusIncrease = radius < highlightRadius * 2 ? .15 : radius < highlightRadius * 3 ? .09 : .02;
opacity = opacity > 255 ? 255 : opacity < 0 ? 0 : opacity;
// prepare new image data with 24-bit direct palette to hold shadowed copy of image
ImageData newImageData = new ImageData(originalImageData.width + radius * 2, originalImageData.height + radius
* 2, 24, new PaletteData(0xFF, 0xFF00, 0xFF0000));
int[] pixels = new int[originalImageData.width];
// copy image data
for (int row = radius; row < radius + originalImageData.height; row++) {
originalImageData.getPixels(0, row - radius, originalImageData.width, pixels, 0);
for (int col = 0; col < pixels.length; col++)
pixels[col] = newImageData.palette.getPixel(originalImageData.palette.getRGB(pixels[col]));
newImageData.setPixels(radius, row, originalImageData.width, pixels, 0);
}
// initialize glow pixel data
int colorInt = newImageData.palette.getPixel(color.getRGB());
pixels = new int[newImageData.width];
for (int i = 0; i < newImageData.width; i++) {
pixels[i] = colorInt;
}
// initialize alpha values
byte[] alphas = new byte[newImageData.width];
// deal with alpha values on rows above and below the photo
for (int row = 0; row < newImageData.height; row++) {
if (row < radius) {
// only calculate alpha values for top border. they will reflect to the bottom border
byte intensity = (byte) (opacity * ((((row + 1)) / (double) (radius))));
for (int col = 0; col < alphas.length / 2 + alphas.length % 2; col++) {
if (col < radius) {
// deal with corners:
// calculate pixel's distance from image corner
double hypotenuse = Math
.sqrt(Math.pow(radius - col - 1, 2.0) + Math.pow(radius - 1 - row, 2.0));
// calculate alpha based on percent distance from image
alphas[col + shift] = alphas[alphas.length - col - 1] = (byte) (opacity * Math.max(
((radius - hypotenuse) / radius), 0));
// add highlight radius
if (hypotenuse < Math.min(highlightRadius, radius * .5)) {
alphas[col + shift] = alphas[alphas.length - col - 1] = (byte) Math.min(255, (alphas[col
+ shift] & 0x0FF)
* (1 + highlightRadiusIncrease * Math.max(((radius - hypotenuse) / radius), 0)));
}
} else {
alphas[col + shift] = alphas[alphas.length - col - 1] = (byte) ((row > Math.max(radius
- highlightRadius - 1, radius * .5)) ? Math.min(255, (intensity & 0x0FF)
* (1 + highlightRadiusIncrease * row / radius)) : intensity);
}
}
if (row + shift < newImageData.height) {
newImageData.setAlphas(newImageData.width - radius, row + shift, radius, alphas, alphas.length
- radius);
newImageData.setPixels(newImageData.width - radius, row + shift, radius, pixels, alphas.length
- radius);
}
newImageData.setAlphas(0, newImageData.height - 1 - row, newImageData.width, alphas, 0);
newImageData.setPixels(0, newImageData.height - 1 - row, newImageData.width, pixels, 0);
}
// deal with rows the image resides on
else if (row <= newImageData.height / 2) {
// calculate alpha values
double intensity = 0;
for (int col = 0; col < alphas.length; col++) {
if (col < radius) {
intensity = (opacity * ((col + 1) / (double) radius));
if (col > Math.max(radius - highlightRadius - 1, radius * .5)) {
intensity = Math.min(255, (intensity) * (1 + highlightRadiusIncrease * col / radius));
}
alphas[newImageData.width - col - 1] = (byte) (int) (intensity);
alphas[col] = 0;
} else if (col <= newImageData.width / 2 + newImageData.width % 2) {
// original image pixels are full opacity
alphas[col] = alphas[newImageData.width - col - 1] = (byte) (255);
}
}
newImageData.setPixels(0, newImageData.height - 1 - row, radius, pixels, 0);
newImageData.setPixels(originalImageData.width + radius, newImageData.height - 1 - row, radius, pixels,
0);
newImageData.setAlphas(0, newImageData.height - 1 - row, newImageData.width, alphas, 0);
if (row >= shift + radius) {
newImageData.setPixels(0, row, radius, pixels, 0);
newImageData.setPixels(originalImageData.width + radius, row, radius, pixels, 0);
newImageData.setAlphas(0, row, newImageData.width, alphas, 0);
} else {
newImageData.setPixels(0, row, radius, pixels, 0);
newImageData.setAlphas(0, row, newImageData.width - radius, alphas, 0);
}
}
}
return newImageData;
}
/**
* Create an image with a glow effect. This method is (c) 2007 Nicholas Rajendram, IBM Canada, see
* http://www.eclipse.org/articles/article.php?file=Article-SimpleImageEffectsForSWT/index.html.
*
* @param originalImageData The original image. Transparency information will be ignored.
* @param color The color of the glow
* @param radius The radius of the glow in pixels
* @param highlightRadius The radius of the highlight area
* @param opacity The opacity of the glow
* @return The glowing image. This image data will be larger than the original. The same image data will be returned
* if the glow radius is 0, or null if an error occured.
*/
public static ImageData glow(ImageData originalImageData, Color color, int radius, int highlightRadius, int opacity) {
/*
* This method will surround an existing image with a glowing border. This glow is created by adding a solid
* colored border around an image. Alpha values are then manipulated in order to blend the border with its
* background. This gives a glowing appearance.
*
* To obtain the alpha value of a glow pixel, its position in the border radius as a percent of the radius'
* total width is first calculated. This percentage is multipled by the maximum opacity level, giving pixels an
* outward linear blend from the image from opaque to transparent.
*
* A highlight radius increases the intensity of a given radius of pixels surrounding the image to better
* highlight it. When there is a highlight radius, the entire glow's overall alpha blending is non-linear.
*/
if (originalImageData == null)
return null;
if (color == null)
return null;
if (radius == 0)
return originalImageData;
// the percent increase in color intensity in the highlight radius
double highlightRadiusIncrease = radius < highlightRadius * 2 ? .15 : radius < highlightRadius * 3 ? .09 : .02;
opacity = opacity > 255 ? 255 : opacity < 0 ? 0 : opacity;
// prepare new image data with 24-bit direct palette to hold glowing copy of image
ImageData newImageData = new ImageData(originalImageData.width + radius * 2, originalImageData.height + radius
* 2, 24, new PaletteData(0xFF, 0xFF00, 0xFF0000));
int[] pixels = new int[originalImageData.width];
// copy image data
for (int row = radius; row < radius + originalImageData.height; row++) {
originalImageData.getPixels(0, row - radius, originalImageData.width, pixels, 0);
for (int col = 0; col < pixels.length; col++)
pixels[col] = newImageData.palette.getPixel(originalImageData.palette.getRGB(pixels[col]));
newImageData.setPixels(radius, row, originalImageData.width, pixels, 0);
}
// initialize glow pixel data
int colorInt = newImageData.palette.getPixel(color.getRGB());
pixels = new int[newImageData.width];
for (int i = 0; i < newImageData.width; i++) {
pixels[i] = colorInt;
}
// initialize alpha values
byte[] alphas = new byte[newImageData.width];
// deal with alpha values on rows above and below the photo
for (int row = 0; row < newImageData.height; row++) {
if (row < radius) {
// only calculate alpha values for top border. they will reflect to the bottom border
byte intensity = (byte) (opacity * ((((row + 1)) / (double) (radius))));
for (int col = 0; col < alphas.length / 2 + alphas.length % 2; col++) {
if (col < radius) {
// deal with corners:
// calculate pixel's distance from image corner
double hypotenuse = Math
.sqrt(Math.pow(radius - col - 1, 2.0) + Math.pow(radius - 1 - row, 2.0));
// calculate alpha based on percent distance from image
alphas[col] = alphas[alphas.length - col - 1] = (byte) (opacity * Math.max(
((radius - hypotenuse) / radius), 0));
// add highlight radius
if (hypotenuse < Math.min(highlightRadius, radius * .5)) {
alphas[col] = alphas[alphas.length - col - 1] = (byte) Math.min(255, (alphas[col] & 0x0FF)
* (1 + highlightRadiusIncrease * Math.max(((radius - hypotenuse) / radius), 0)));
}
} else {
alphas[col] = alphas[alphas.length - 1 - col] = (byte) ((row > Math.max(radius
- highlightRadius - 1, radius * .5)) ? Math.min(255, (intensity & 0x0FF)
* (1 + highlightRadiusIncrease * row / radius)) : intensity);
}
}
newImageData.setAlphas(0, row, newImageData.width, alphas, 0);
newImageData.setAlphas(0, newImageData.height - 1 - row, newImageData.width, alphas, 0);
newImageData.setPixels(0, row, newImageData.width, pixels, 0);
newImageData.setPixels(0, newImageData.height - 1 - row, newImageData.width, pixels, 0);
}
// deal with rows the image resides on
else if (row <= newImageData.height / 2) {
// calculate alpha values
double intensity = 0;
for (int col = 0; col < alphas.length; col++) {
if (col < radius) {
intensity = (opacity * ((col + 1) / (double) radius));
if (col > Math.max(radius - highlightRadius - 1, radius * .5)) {
intensity = Math.min(255, (intensity) * (1 + highlightRadiusIncrease * col / radius));
}
alphas[col] = alphas[newImageData.width - col - 1] = (byte) (intensity);
} else if (col <= newImageData.width / 2 + newImageData.width % 2) {
// original image pixels are full opacity
alphas[col] = alphas[newImageData.width - col - 1] = (byte) (255);
}
}
newImageData.setPixels(0, row, radius, pixels, 0);
newImageData.setPixels(originalImageData.width + radius, row, radius, pixels, 0);
newImageData.setAlphas(0, row, newImageData.width, alphas, 0);
newImageData.setPixels(0, newImageData.height - 1 - row, radius, pixels, 0);
newImageData.setPixels(originalImageData.width + radius, newImageData.height - 1 - row, radius, pixels,
0);
newImageData.setAlphas(0, newImageData.height - 1 - row, newImageData.width, alphas, 0);
}
}
return newImageData;
}
/**
* Create a reflection image (Idea taken from Daniel Spiewak: see
* http://www.eclipsezone.com/eclipse/forums/t91013.html?start=0).
*
* @param img image to reflect
* @param device device
* @return image (larger than the original) containing a reflectd version of the original image
*/
public static Image reflect(Image img, Device device) {
int height = img.getImageData().height;
int width = img.getImageData().width;
Image reflect = new Image(device, width, height / 2);
GC imageGC = new GC(reflect);
Transform rTransform = new Transform(imageGC.getDevice(), 1, 0, 0, -.5f, 0, height / 2);
imageGC.setTransform(rTransform);
imageGC.setAlpha(100);
imageGC.drawImage(img, 0, 0);
// imageGC.setTransform(null);
// // shade it
// int alpha =100;
// imageGC.setAlpha(100);
// imageGC.setForeground(imageGC.getDevice().getSystemColor(SWT.COLOR_WHITE));
// for (int y = 0;y<height/2;y++) {
// imageGC.setAlpha(alpha);
// imageGC.drawLine(0, y, width, y);
// alpha = alpha + 255/height;
// System.out.println("ALPHA "+alpha+" y "+y);
// }
imageGC.dispose();
return reflect;
}
}
@@ -0,0 +1,313 @@
/*
* File: TextRenderer.java
* Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de)
* A commercial license is available, see http://www.jaret.de.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*/
package de.jaret.util.swt;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
/**
* Simple utility class for rendering a multiline text.
*
* @author Peter Kliem
* @version $Id: TextRenderer.java 623 2007-11-01 15:23:45Z kliem $
*
* Modified by Loris Securo for CustomButton
*/
@SuppressWarnings({"rawtypes"})
public class TextRenderer {
public static final int LEFT = 0;
public static final int RIGHT = 1;
public static final int CENTER = 2;
public static final int TOP = 0;
public static final int BOTTOM = 1;
public static void renderText(GC gc, Rectangle rect, boolean wrap,
boolean ellipsis, String text) {
renderText(gc, rect, wrap, ellipsis, text, LEFT, TOP);
}
public static void renderText(GC gc, Rectangle rect, boolean wrap,
boolean ellipsis, String text, int halign, int valign) {
renderText(gc, rect, wrap, ellipsis, text, halign, valign, true, 3,
false);
}
public static void renderText(GC gc, Rectangle rect, boolean wrap,
boolean ellipsis, String text, int halign, int valign,
boolean isTransparent, int lineSpacing, boolean textResize) {
Rectangle clipSave = gc.getClipping();
gc.setClipping(rect.intersection(clipSave));
List<String> lines = breakInLines(gc, rect.width, wrap, text);
if (!textResize || lines.size() != 1) {
int height = getHeight(gc, rect.width, wrap, lines, lineSpacing);
int offy = 0;
if (height < rect.height) {
if (valign == CENTER) {
offy = (rect.height - height) / 2;
} else if (valign == BOTTOM) {
offy = rect.height - height;
}
}
int lineheight = SwtGraphicsHelper.getStringDrawingHeight(gc,
"WgyAqQ");
for (int row = 0; row < lines.size(); row++) {
int y = rect.y + (row * lineheight) + (row * lineSpacing);
drawLine(gc, rect.x, y + offy, rect.width, lines.get(row),
halign, isTransparent);
}
} else {
drawLineResize(gc, rect.x, rect.y, rect.width, rect.height,
lines.get(0), halign, valign, isTransparent);
}
gc.setClipping(clipSave);
}
public static int getHeight(GC gc, int width, boolean wrap, String text) {
List<String> lines = breakInLines(gc, width, wrap, text);
return getHeight(gc, width, wrap, lines, 3);
}
public static int getHeight(GC gc, int width, boolean wrap, String text,
int lineSpacing) {
List<String> lines = breakInLines(gc, width, wrap, text);
return getHeight(gc, width, wrap, lines, lineSpacing);
}
private static int getHeight(GC gc, int width, boolean wrap,
List<String> lines, int lineSpacing) {
if (lines.size() == 0) {
return 0;
}
int lineheight = SwtGraphicsHelper.getStringDrawingHeight(gc,
lines.get(0));
int height = (lines.size() * lineheight)
+ ((lines.size() - 1) * lineSpacing);
return height;
}
private static void drawLine(GC gc, int x, int y, int width, String string,
int halign, boolean isTransparent) {
int xx;
int textWidth = SwtGraphicsHelper.getStringDrawingWidth(gc, string);
switch (halign) {
case LEFT:
xx = x;
break;
case RIGHT:
xx = x + (width - textWidth);
break;
case CENTER:
xx = x + ((width - textWidth) / 2);
break;
default:
throw new RuntimeException("illegal alignment");
}
gc.drawText(string, xx, y, isTransparent);
}
private static void drawLineResize(GC gc, int x, int y, int width,
int height, String string, int halign, int valign,
boolean isTransparent) {
int xx;
int textWidth = SwtGraphicsHelper.getStringDrawingWidth(gc, string);
double widthRatio = (double) width / (double) textWidth;
Font gcFont = gc.getFont();
FontData[] fontData = gcFont.getFontData();
Display display = Display.getCurrent();
Font systemFont = display.getSystemFont();
FontData[] systemFontData = systemFont.getFontData();
int newFontSize = (int) (fontData[0].getHeight() * widthRatio);
if (newFontSize != fontData[0].getHeight()) {
fontData[0].setHeight(newFontSize);
gc.setFont(new Font(display, fontData[0]));
while (SwtGraphicsHelper.getStringDrawingWidth(gc, string) < width
&& SwtGraphicsHelper.getStringDrawingHeight(gc, string) < height) {
newFontSize++;
fontData[0].setHeight(newFontSize);
gc.getFont().dispose();
gc.setFont(new Font(display, fontData[0]));
}
while (SwtGraphicsHelper.getStringDrawingWidth(gc, string) > width
|| SwtGraphicsHelper.getStringDrawingHeight(gc, string) > height) {
newFontSize--;
fontData[0].setHeight(newFontSize);
gc.getFont().dispose();
gc.setFont(new Font(display, fontData[0]));
if (newFontSize <= systemFontData[0].getHeight()) {
break;
}
}
if (newFontSize < systemFontData[0].getHeight()) {
newFontSize = systemFontData[0].getHeight();
fontData[0].setHeight(newFontSize);
gc.getFont().dispose();
gc.setFont(new Font(display, fontData[0]));
}
}
int textHeight = SwtGraphicsHelper.getStringDrawingHeight(gc, string);
if (textHeight < height) {
if (valign == CENTER) {
y += (height / 2) - (textHeight / 2);
} else if (valign == BOTTOM) {
y += height - textHeight;
}
}
textWidth = SwtGraphicsHelper.getStringDrawingWidth(gc, string);
switch (halign) {
case LEFT:
xx = x;
break;
case RIGHT:
xx = x + (width - textWidth);
break;
case CENTER:
xx = x + ((width - textWidth) / 2);
break;
default:
throw new RuntimeException("illegal alignment");
}
gc.drawText(string, xx, y, isTransparent);
if (gc.getFont() != gcFont && gc.getFont() != systemFont) {
gc.getFont().dispose();
}
}
public static List<String> breakInLines(GC gc, int width, boolean wrap,
String text) {
List<String> result = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(text, "\n", false);
while (tokenizer.hasMoreTokens()) {
result.add(tokenizer.nextToken());
}
if (wrap) {
List<String> brokenLines = new ArrayList<String>();
Iterator it = result.iterator();
while (it.hasNext()) {
String line = (String) it.next();
List<String> brLines = wrapLines(gc, width, line);
brokenLines.addAll(brLines);
}
return brokenLines;
} else {
return result;
}
}
/**
* @param gc
* @param width
* @param text
* @return
*/
private static List<String> wrapLines(GC gc, int width, String text) {
List<String> result = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(text, " ", false);
StringBuffer buf = new StringBuffer();
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
addToken(gc, width, buf, token, result);
}
if (buf.length() > 0) {
result.add(buf.toString());
}
return result;
}
private static void addToken(GC gc, int width, StringBuffer buf,
String token, List<String> result) {
String testString;
if (buf.length() > 0) {
testString = " " + token;
} else {
testString = token;
}
if (SwtGraphicsHelper.getStringDrawingWidth(gc, buf.toString()
+ testString) < width) {
buf.append(testString);
} else if (buf.length() == 0) {
// a single word did not fit
List<String> brWord = breakWord(gc, width, token);
if (brWord.size() == 1) {
result.add(brWord.get(0));
} else {
for (int i = 0; i < (brWord.size() - 1); i++) {
result.add(brWord.get(i));
}
addToken(gc, width, buf, brWord.get(brWord.size() - 1), result);
}
} else {
result.add(buf.toString());
buf.setLength(0);
addToken(gc, width, buf, token, result);
}
}
/**
* break a word into strings fitting into width.
*
* @param gc
* @param width
* @param word
* @return
*/
private static List<String> breakWord(GC gc, int width, String word) {
List<String> result = new ArrayList<String>();
for (int bidx = 0, eidx = 1; eidx <= word.length(); eidx++) {
String wordPart = word.substring(bidx, eidx);
int wordPartExtent = SwtGraphicsHelper.getStringDrawingWidth(gc,
wordPart);
if (wordPartExtent > width) {
if ((eidx - 1) > bidx) {
eidx--;
}
result.add(word.substring(bidx, eidx));
bidx = eidx;
} else if (eidx == word.length()) {
result.add(word.substring(bidx, eidx));
}
}
return result;
}
}
+7
View File
@@ -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 exported="true" kind="lib" path="KTable.jar" sourcepath="source.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -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>de.kupzog.ktable</artifactId>
<version>2.2.0</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] de.kupzog.ktable</name>
</project>
+45
View File
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>de.kupzog.ktable</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>1779484362510</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>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
Binary file not shown.
@@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: de.kupzog.ktable
Bundle-Version: 2.2.0
Bundle-ClassPath: .,
KTable.jar
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: de.kupzog.ktable,
de.kupzog.ktable.editors,
de.kupzog.ktable.renderers,
icons
Require-Bundle: org.eclipse.jface
Automatic-Module-Name: de.kupzog.ktable
@@ -0,0 +1,2 @@
#Properties file for de.kupzog.ktable
Bundle-Name = de.kupzog.ktable
@@ -0,0 +1,3 @@
bin.includes = META-INF/,\
KTable.jar,\
OSGI-INF/
Binary file not shown.
@@ -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>
@@ -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.application.constants</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Events</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.application.constants</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>1779484362512</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>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -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
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,8 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: flintstones.application.constants
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: flintstones.application.constants
Automatic-Module-Name: flintstones.framework.events
@@ -0,0 +1,2 @@
#Properties file for flintstones.framework.events
Bundle-Name = Events
@@ -0,0 +1,2 @@
#Properties file for flintstones.framework.events
Bundle-Name = Events
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/l10n/bundle.properties,\
OSGI-INF/
@@ -0,0 +1,68 @@
package flintstones.application.constants;
@SuppressWarnings("javadoc")
public interface ApplicationContants {
String MWindow_Main = "flintstones.application.trimmedwindow.flintstones";
// 0.APP MAIN MENU
String MHandledToolItem_Menu_FrameworkStructuring = "flintstones.application.toolbar.perspectiveswitcher.handledtoolitem.frameworkstructuring";
String MHandledToolItem_Menu_Gathering = "flintstones.application.toolbar.perspectiveswitcher.handledtoolitem.gathering";
String MHandledToolItem_Change_Problem_Type = "flintstones.application.directtoolitem.problem.type";
// 1.FRAMEWORK
String MPartStack_Domain = "flintstones.framework.ui.partstack.domains";
String MPartStack_DomainViewer = "flintstones.framework.ui.partstack.domain";
String MPartStack_AHPClasses = "flintstones.framework.ui.partstack.ahpclasses";
String MPartStack_AHPPRofiles = "flintstones.framework.ui.partstack.ahpprofiles";
String MPartStack_AHPViewer = "flintstones.framework.ui.partstack.ahpviewer";
// 3.GATHERING
String MPart_Gatehring_Selector = "flintstones.gathering.ui.part.selectorpart";
// 3 - Generic AHP GATHERING
String MPartStack_AHP_Gathering = "flintstones.application.perspective.ahpgathering.partstack";
String MPartStack_AHP_Comparing = "flintstones.application.perspective.ahpcomparing.partstack";
String MPerspective_AHP_Comparing = "flintstones.application.perspective.ahpcomparing";
String MPerspective_AHP_Gathering = "flintstones.application.perspective.ahpgathering";
String MPerspective_AHP = "flintstones.application.perspective.ahpgathering";
// 3.GATHERING AHP
String MPerspective_Rating_AHP = "flintstones.application.perspective.gathering.ahp.ui";
// 3.GATHERING AHPSORT
String MPerspective_Rating_AHPSort = "flintstones.application.perspective.gathering.ahpsort.ui";
// 3.GATHERING AHPSORTII
String MPart_Gathering_ReferencePoints = "flintstones.application.perspective.gathering.ahpsortii.ui.referencepoints";
// 4.RATING
String MMenu_Rating = "flintstones.application.menu.rating";
String MPerspective_Rating = "flintstones.application.perspective.rating";
// 4.Rating > Select Method Menu
String MCommand_Rating_Selectmethod = "flintstones.application.command.rating.selectmethod";
String MHandler_Rating_Selectmethod = "flintstones.application.handler.rating.selectmethod";
String MParameter_Rating_Selectmethod = "flintstones.application.commandparameter.rating.selectmethod";
String MParameter_Rating_Selectmethod__label = "method_id";
// 4.1
String MPerspective_Phase = "flintstones.application.perspective.phase";
String MPartSashContainer_Phase_Container = "flintstones.application.perspective.phase.ui.partsashcontainer.container";
// 4.1 - Aggregation
String MPerspective_Phase_Phantom = "flintstones.application.perspective.phase.phantomphasecontainer";
// Select Locale Menu
String MCommand_Global_Selectlocale = "flintstones.application.command.locale";
String MParameter_Global_Selectlocale = "flintstones.application.commandparameter.localeId";
// Debug > Send broker events menu
String MMenu_Sendbroker = "flintstones.application.menu.sendbroker";
String MCommand_General_Sendbroker = "flintstones.application.command.debug.sendbroker";
String MHandler_General_Sendbroker = "flintstones.application.handler.debug.sendbroker";
String MParameter_General_Sendbroker = "flintstones.application.commandparameter.debug.sendbroker.brokerevent";
String MParameter__General_Sendbroker__label = "event_id";
}
@@ -0,0 +1,91 @@
package flintstones.application.constants;
import java.util.HashMap;
import java.util.Map;
/**
* @noimplement This interface is not intended to be implemented.
*
* Only used for constants definitions.
*
*/
@SuppressWarnings({ "nls", "javadoc" })
public interface FrameworkConstants {
String TOPIC_FRAMEWORK = "TOPIC_FRAMEWORK";
String TOPIC_FRAMEWORK_ALLTOPICS = "TOPIC_FRAMEWORK/*";
String TOPIC_FRAMEWORK_ALTERNATIVE_ALLTOPICS = "TOPIC_FRAMEWORK/PROBLEMELEMENT/ALTERNATIVE/*";
String TOPIC_FRAMEWORK_ALTERNATIVE_MODIFIED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/ALTERNATIVE/MODIFIED";
String TOPIC_FRAMEWORK_ALTERNATIVE_CREATED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/ALTERNATIVE/CREATED";
String TOPIC_FRAMEWORK_ALTERNATIVE_DELETED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/ALTERNATIVE/DELETED";
String TOPIC_FRAMEWORK_EXPERT_ALLTOPICS = "TOPIC_FRAMEWORK/PROBLEMELEMENT/EXPERT/*";
String TOPIC_FRAMEWORK_EXPERT_CREATED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/EXPERT/CREATED";
String TOPIC_FRAMEWORK_EXPERT_MODIFIED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/EXPERT/MODIFIED";
String TOPIC_FRAMEWORK_EXPERT_DELETED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/EXPERT/DELETED";
String TOPIC_FRAMEWORK_CRITERION_ALLTOPICS = "TOPIC_FRAMEWORK/PROBLEMELEMENT/CRITERION/*";
String TOPIC_FRAMEWORK_CRITERION_CREATED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/CRITERION/CREATED";
String TOPIC_FRAMEWORK_CRITERION_MODIFIED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/CRITERION/MODIFIED";
String TOPIC_FRAMEWORK_CRITERION_DELETED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/CRITERION/DELETED";
String TOPIC_FRAMEWORK_SORTINGCLASS_ALLTOPICS = "TOPIC_FRAMEWORK/PROBLEMELEMENT/SORTINGCLASS/*";
String TOPIC_FRAMEWORK_SORTINGCLASS_MODIFIED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/SORTINGCLASS/MODIFIED";
String TOPIC_FRAMEWORK_SORTINGCLASS_CREATED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/SORTINGCLASS/CREATED";
String TOPIC_FRAMEWORK_SORTINGCLASS_DELETED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/SORTINGCLASS/DELETED";
String TOPIC_FRAMEWORK_SORTINGPROFILE_ALLTOPICS = "TOPIC_FRAMEWORK/PROBLEMELEMENT/SORTINGPROFILE/*";
String TOPIC_FRAMEWORK_SORTINGPROFILE_MODIFIED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/SORTINGPROFILE/MODIFIED";
String TOPIC_FRAMEWORK_SORTINGPROFILE_CREATED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/SORTINGPROFILE/CREATED";
String TOPIC_FRAMEWORK_SORTINGPROFILE_DELETED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/SORTINGPROFILE/DELETED";
String TOPIC_FRAMEWORK_PROBLEMELEMENT_ALLTOPICS = "TOPIC_FRAMEWORK/PROBLEMELEMENT/*";
String TOPIC_FRAMEWORK_PROBLEMELEMENT_MODIFIED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/MODIFIED";
String TOPIC_FRAMEWORK_PROBLEMELEMENT_CREATED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/CREATED";
String TOPIC_FRAMEWORK_PROBLEMELEMENT_DELETED = "TOPIC_FRAMEWORK/PROBLEMELEMENT/DELETED";
String TOPIC_FRAMEWORK_DOMAIN_ALLTOPICS = "TOPIC_FRAMEWORK/DOMAIN/*";
String TOPIC_FRAMEWORK_DOMAIN_CREATED = "TOPIC_FRAMEWORK/DOMAIN/CREATED";
String TOPIC_FRAMEWORK_DOMAIN_MODIFIED = "TOPIC_FRAMEWORK/DOMAIN/MODIFIED";
String TOPIC_FRAMEWORK_DOMAIN_DELETED = "TOPIC_FRAMEWORK/DOMAIN/DELETED";
String TOPIC_VALUATION = "TOPIC_VALUATION";
String TOPIC_VALUATION_ALLTOPICS = "TOPIC_VALUATION/*";
String TOPIC_VALUATION_MODIFIED = "TOPIC_VALUATION/MODIFIED";
String TOPIC_VALUATION_CREATED = "TOPIC_VALUATION/CREATED";
String TOPIC_VALUATION_DELETED = "TOPIC_VALUATION/DELETED";
String TOPIC_VALUATION_ASSIGNED = "TOPIC_VALUATION/ASSIGNED";
String TOPIC_METHOD_ALLTOPICS = "TOPIC_METHOD/*";
String TOPIC_METHOD_LOAD = "TOPIC_METHOD/LOAD";
String TOPIC_METHOD_PHASE_REFRESH = "TOPIC_METHOD/PHASE/REFRESH";
String TOPIC_METHOD_PHASE_POSTCONSTRUCT = "TOPIC_METHOD/PHASE/POSTCONSTRUCT";
String TOPIC_METHOD_PHASE_PHANTOM = "TOPIC_METHOD/PHASE/PHANTOM";
String TOPIC_METHOD_PHASE_PHANTOM_RESPONSE = "TOPIC_METHOD/PHASE/PHANTOM_RESPONSE";
String TOPIC_PERSPECTIVE_ALLTOPICS = "TOPIC_PERSPECTIVE/*";
String TOPIC_PERSPECTIVE_CHANGE = "TOPIC_PERSPECTIVE/CHANGE";
String TOPIC_SELECTION_VALUATION = "TOPIC_SELECTION/VALUATION";
String TOPIC_SELECTION_FRAMEWORK_ALLTOPICS = "TOPIC_SELECTION/FRAMEWORK/*";
String TOPIC_SELECTION_FRAMEWORK_DOMAIN = "TOPIC_SELECTION/FRAMEWORK/DOMAIN";
String TOPIC_SELECTION_FRAMEWORK_PROBLEMELEMENT = "TOPIC_SELECTION/FRAMEWORK/PROBLEMELEMENT";
String TOPIC_SELECTION_METHOD = "TOPIC_SELECTION/METHOD";
String TOPIC_SELECTION_DOCUMENTATION = "TOPIC_SELECTION/DOCUMENTATION";
public static Map<String, Object> map(String key, Object item) {
Map<String, Object> m = new HashMap<>();
m.put(key, item);
return m;
}
public static Map<String, Object> empty(){
Map<String, Object> m = new HashMap<>();
return m;
}
}
@@ -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>
@@ -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.application.control</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Control</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.application.control</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>1779484362513</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>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -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
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Control
Bundle-SymbolicName: flintstones.application.control
Bundle-Version: 1.0.0.qualifier
Require-Bundle: flintstones.application,
flintstones.model.application.service,
flintstones.model.ui.service,
flintstones.helper.ui,
org.eclipse.e4.core.services,
org.eclipse.e4.ui.services,
org.eclipse.e4.core.contexts,
org.eclipse.e4.core.di,
javax.inject,
javax.annotation
Automatic-Module-Name: flintstones.application.control
Bundle-RequiredExecutionEnvironment: JavaSE-11
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -0,0 +1,57 @@
package flintstones.application.control;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import flintstones.model.ui.service.UiService;
/**
* The Class ConsolaControl.
*/
public class ConsolaControl {
/** The context. */
@Inject
IEclipseContext context;
/** The text. */
private Text text;
/**
* Creates the part control.
*
* @param parent the parent
*/
@PostConstruct
public void createPartControl(Composite parent) {
text = new Text(parent, SWT.READ_ONLY | SWT.MULTI);
OutputStream out = new OutputStream() {
@Override
public void write(int b) throws IOException {
if (text.isDisposed())
return;
text.append(String.valueOf((char) b));
}
};
final PrintStream oldOut = System.out;
System.setOut(new PrintStream(out));
text.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
System.setOut(oldOut);
}
});
text.setBackground(UiService.getColor(255));
}
}
@@ -0,0 +1,17 @@
package flintstones.application.control;
import javax.annotation.PostConstruct;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
@SuppressWarnings("javadoc")
public class SpacerControl {
@PostConstruct
public void postConstruct(final Composite parent) {
Composite body = new Composite(parent, SWT.NONE);
body.setLayout(new FillLayout());
}
}
@@ -0,0 +1,25 @@
package flintstones.application.control.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.application.model.IApplicationService;
/**
* The Class ExitHandler. Hanlder that close the app.
*/
public class ExitHandler {
/** The app service. */
@Inject
IApplicationService appService;
/**
* Execute.
*/
@Execute
public void execute() {
this.appService.close();
}
}
@@ -0,0 +1,37 @@
package flintstones.application.control.handler;
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.Execute;
import flintstones.application.model.IApplicationService;
import flintstones.application.handlers.PerspectiveSwitcher;
/**
* The Class NewHandler creates a new proyect.
*/
public class NewHandler {
/** The context. */
@Inject
IEclipseContext context;
/** The app service. */
@Inject
IApplicationService appService;
/**
* Execute.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
@Execute
public void execute() {
this.appService.newProblem();
ContextInjectionFactory.make(PerspectiveSwitcher.class, context).changePerspective("flintstones.application.perspective.framework");
}
}
@@ -0,0 +1,30 @@
package flintstones.application.control.handler;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.application.model.IApplicationService;
public class OpenFs4FolderHandler {
@Inject
IApplicationService appService;
@Execute
public void execute() {
String folder = appService.getFS4FolderPath();
try {
Desktop.getDesktop().open(new File(folder));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@@ -0,0 +1,65 @@
package flintstones.application.control.handler;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import flintstones.application.model.IApplicationService;
/**
* The Class OpenHandler opens a file from disk.
*/
public class OpenHandler {
/** The context. */
@Inject
IEclipseContext context;
/** The broker. */
@Inject
IEventBroker broker;
/** The app service. */
@Inject
IApplicationService appService;
/** The shell. */
@Inject
@Named(IServiceConstants.ACTIVE_SHELL)
Shell shell;
/** The Constant FILTER_NAMES. */
private static final String[] FILTER_NAMES = { "Flintstones files (*.flintstones)", "XML(*.xml)" }; //$NON-NLS-1$ //$NON-NLS-2$
/** The Constant FILTER_EXTS. */
private static final String[] FILTER_EXTS = { "*.flintstones", "*.xml" }; //$NON-NLS-1$ //$NON-NLS-2$
/**
* Execute.
*
* @throws ParserConfigurationException the parser configuration exception
* @throws IOException Signals that an I/O exception has occurred.
* @throws SAXException the SAX exception
* @throws XMLStreamException the XML stream exception
*/
@Execute
public void execute() {
FileDialog dlg = new FileDialog(this.shell, SWT.OPEN);
dlg.setFilterNames(OpenHandler.FILTER_NAMES);
dlg.setFilterExtensions(OpenHandler.FILTER_EXTS);
dlg.setFilterPath(appService.getFS4FolderPath());
String fileName = dlg.open();
if (fileName != null)
this.appService.loadProblem(fileName);
}
}
@@ -0,0 +1,11 @@
package flintstones.application.control.handler;
import org.eclipse.e4.core.di.annotations.Execute;
@SuppressWarnings("javadoc")
public class RedoHandler {
@Execute
public void execute() {
System.err.println("Redo handler called."); //$NON-NLS-1$
}
}
@@ -0,0 +1,11 @@
package flintstones.application.control.handler;
import org.eclipse.e4.core.di.annotations.Execute;
@SuppressWarnings("javadoc")
public class SaveAndCloseHandler {
@Execute
public void execute() {
// System.out.println("Save and close handler called."); //$NON-NLS-1$
}
}
@@ -0,0 +1,63 @@
package flintstones.application.control.handler;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import flintstones.application.model.IApplicationService;
/**
* The Class SaveAsHandler.
*/
public class SaveAsHandler {
/** The context. */
@Inject
IEclipseContext context;
/** The broker. */
@Inject
IEventBroker broker;
/** The app service. */
@Inject
IApplicationService appService;
/** The shell. */
@Inject
@Named(IServiceConstants.ACTIVE_SHELL)
Shell shell;
/** The Constant FILTER_NAMES. */
private static final String[] FILTER_NAMES = { "Flintstones files (*.flintstones)" }; //$NON-NLS-1$
/** The Constant FILTER_EXTS. */
private static final String[] FILTER_EXTS = { "*.flintstones" }; //$NON-NLS-1$
/**
* Execute.
*
* @throws ParserConfigurationException the parser configuration exception
* @throws IOException Signals that an I/O exception has occurred.
* @throws SAXException the SAX exception
* @throws XMLStreamException the XML stream exception
*/
@Execute
public void execute() {
FileDialog dlg = new FileDialog(this.shell, SWT.SAVE);
dlg.setFilterNames(SaveAsHandler.FILTER_NAMES);
dlg.setFilterExtensions(SaveAsHandler.FILTER_EXTS);
String fileName = dlg.open();
if (fileName != null)
this.appService.saveProblemAs(fileName);
}
}
@@ -0,0 +1,26 @@
package flintstones.application.control.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.application.model.IApplicationService;
/**
* The Class SaveHandler.
*/
public class SaveHandler {
/** The app service. */
@Inject
IApplicationService appService;
/**
* Execute.
*/
@Execute
public void execute() {
this.appService.saveProblem();
}
}
@@ -0,0 +1,11 @@
package flintstones.application.control.handler;
import org.eclipse.e4.core.di.annotations.Execute;
@SuppressWarnings("javadoc")
public class UndoHandler {
@Execute
public void execute() {
System.err.println("Undo handler called."); //$NON-NLS-1$
}
}
@@ -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>
@@ -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.application.debug</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Debug</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.application.debug</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>1779484362514</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>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -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
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,44 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Debug
Bundle-SymbolicName: flintstones.application.debug;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.application.debug
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: flintstones.helper.data,
javax.inject,
flintstones.model.problemelement.service,
flintstones.model.valuation.service,
flintstones.entity.valuation,
flintstones.entity.problemelement,
flintstones.application.constants,
flintstones.model.domain.ui.service,
org.eclipse.e4.core.contexts,
flintstones.model.domain.service,
flintstones.domain.fuzzyset,
org.apache.commons.lang,
flintstones.model.ahppreferences.service,
flintstones.model.application.service,
flintstones.model.ahpsort.profileassignment.service,
flintstones.operator,
flintstones.valuation.ui,
org.eclipse.e4.ui.workbench,
org.eclipse.e4.core.di,
org.eclipse.jface,
javax.annotation,
flintstones.model.method.service,
flintstones.model.method.phase.service,
flintstones.entity.method.phase.ui,
org.eclipse.e4.ui.model.workbench,
flintstones.model.ahp.referencepoint.service,
flintstones.helper.debug,
flintstones.model.engine.r.service,
flintstones.entity.method.phase,
flintstones.entity.method,
flintstones.domain.numeric.integer,
flintstones.valuation.linguistic,
flintstones.valuation.hesitant,
flintstones.valuation.numeric.real,
flintstones.valuation.numeric.integer
Import-Package: org.eclipse.core.runtime
Export-Package: flintstones.application.debug.handler
@@ -0,0 +1,3 @@
# Wenas info
![imagen](borrar/tpr.jpg)
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
borrar/
@@ -0,0 +1,89 @@
package flintstones.application.debug.addon;
import java.util.Arrays;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.core.contexts.IEclipseContext;
import flintstones.application.model.IApplicationService;
import flintstones.helper.data.text.DebugStream;
import flintstones.helper.debug.DH;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.domain.ui.service.IDomainUIService;
import flintstones.model.engine.r.service.IREngineService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.operator.service.IOperatorService;
// Importante:
// 1 - Nada de javadoc aqui.
// 2 - El cdigo que se quede aqui debe poder borrarse y que todo funcione.
// 3 - Usar solo para pruebas
// 4 - No tocar init ni el constructor. Colocad el programa/prueba en auto()
@SuppressWarnings({ "nls", "javadoc" })
public class AutoAddon {
@Inject
IEclipseContext context;
@Inject
IApplicationService appService;
@Inject
IValuationService valuationService;
@Inject
IDomainService domainService;
@Inject
IDomainUIService domainUI;
@Inject
IOperatorService operatorService;
@Inject
IProblemElementService problemService;
@Inject
IREngineService rService;
public AutoAddon() {
}
@PostConstruct
public void init(IEclipseContext context) {
String[] args = Platform.getCommandLineArgs();
if (Arrays.asList(args).stream().anyMatch(flag -> flag.equals("-autoAddon"))) {
DH.out("!INFO Ejecutando AutoAddon ya que -autoAddon esta presente");
this.auto(context);
}
if (Arrays.asList(args).stream().anyMatch(flag -> flag.equals("-autoSystemOut"))) {
DH.out("!INFO Mejorando System.Out.Print ya que -autoSystemOut esta presente");
DebugStream.activate();
}
// DH.hide("router");
DH.hide("router");
// DH.hide("I/O");
DH.hide("locale");
}
public void auto(IEclipseContext context) {
// ContextInjectionFactory.make(ExecuteDebugHandler.class, context).execute();
// BrowserShell shell = new BrowserShell();
// SvgBrowser br = new SvgBrowser(shell.get());
// br.setCanvas(new SortingDiagram());
// shell.setWidget(br);
// br.render();
//
// shell.open();
}
}
@@ -0,0 +1,36 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import flintstones.application.model.IApplicationService;
import flintstones.application.model.ProblemType;
public class ChangeProblemTypeHandler {
@Inject
IApplicationService appService;
@Inject
EModelService modelService;
@Inject
MApplication application;
@Execute
public void execute() {
ProblemType type = appService.getProblemType();
type = type.equals(ProblemType.Ranking) ? ProblemType.Sorting : ProblemType.Ranking;
appService.launchProblem(type);
// MUIElement uiElement = (MUIElement) modelService.find(ApplicationContants.MHandledToolItem_Change_Problem_Type, this.application); // $NON-NLS-1$
// MHandledToolItem item = (MHandledToolItem)uiElement;
// item.setLabel(type.toString() + " Problem");
}
}
@@ -0,0 +1,49 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.services.events.IEventBroker;
import flintstones.application.constants.FrameworkConstants;
import flintstones.helper.debug.DH;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.valuation.service.IValuationService;
@SuppressWarnings("javadoc")
public class ClearDomainDebugHandler {
/** The broker. */
@Inject
IEventBroker broker;
/** The context. */
@Inject
IEclipseContext context;
@Inject
IDomainService domainService;
@Inject
IValuationService valuationService;
@Execute
public void execute() {
DH.out("[DEBUG] Eliminando todos los dominios" );
domainService.clear();
valuationService.clear();
sendEvents();
}
private void sendEvents() {
this.broker.post(FrameworkConstants.TOPIC_FRAMEWORK_DOMAIN_DELETED, null);
this.broker.post(FrameworkConstants.TOPIC_VALUATION_DELETED, null);
}
}
@@ -0,0 +1,72 @@
package flintstones.application.debug.handler;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.helper.debug.DH;
@SuppressWarnings("javadoc")
public class DumpExtensionPointDataDebugHandler {
@Execute
public void execute() {
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
IExtensionPoint[] extensionPoints = extensionRegistry.getExtensionPoints();
DH.l(5);
DH.out(" MOSTRANDO PUNTOS DE EXTENSIÓN");
DH.out(" RECOMENDADO PEGAR TODO EN UN EDITOR DE TEXTO");
DH.out(" Y FORMATEAR COMO YAML");
DH.l(2);
for(IExtensionPoint extensionPoint : extensionPoints) {
if(extensionPoint.getUniqueIdentifier().contains("flintstones")) {
show(extensionPoint);
DH.l(2);
}
}
}
private void show(IExtensionPoint extensionPoint) {
DH.out("IDENTIFICADOR " + extensionPoint.getUniqueIdentifier() + " ==================================== :" );
// LEVEL 1 - El de eclipse. Tiene X atributos, almenos uno debe ser nuestro.
IExtension[] extensions = extensionPoint.getExtensions();
for(IExtension extension : extensions) {
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
for( IConfigurationElement configElement : configurationElements ) {
showConfig(configElement,2);
DH.out("");
}
}
}
private void showConfig(IConfigurationElement configElement, int level) {
String indentText = new String(new char[level-1]).replace("\0", " ");
DH.out(indentText + configElement.getName()+":");
// LEVEL 2 - AQUí ESTAN NUESTROS VALORES
String[] atributes = configElement.getAttributeNames();
indentText = new String(new char[level]).replace("\0", " ");
for( String atribute : atributes ) {
DH.out( indentText + atribute + " : " + configElement.getAttribute(atribute));
}
// Si hay sub-valores, recursividad
IConfigurationElement[] children = configElement.getChildren();
if( children.length > 0 ) {
for( IConfigurationElement subConfig : children ) {
showConfig(subConfig, level +1);
}
}
}
}
@@ -0,0 +1,59 @@
package flintstones.application.debug.handler;
import java.util.HashMap;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.entity.method.Method;
import flintstones.entity.method.phase.ui.PhaseMethodUI;
import flintstones.helper.data.text.ClassToString;
import flintstones.helper.debug.DH;
import flintstones.model.method.phase.IPhaseMethodService;
import flintstones.model.method.service.IMethodService;
@SuppressWarnings("javadoc")
public class DumpPhasesOutputDebugHandler {
@Inject
IPhaseMethodService phaseService;
@Inject
IMethodService methodService;
@Execute
public void execute() {
DH.l();
PhaseMethodUI[] phases = phaseService.getAll();
for (PhaseMethodUI phase : phases) {
DH.out("===== Export " + phase.getModel().getName() + "(" + phase.getPosition() + ")" + " - "
+ phase.getModel().getId());
DH.out(phase.getModel().getExportedSummary() + "\n");
}
DH.l(3);
for(Method m : methodService.getAll()) {
HashMap<String, Object> data = m.getExportedData();
DH.out("===== Export " + m.getName() + " - "+ m.getId());
for(Entry<String,Object> entry : data.entrySet()) {
String key = entry.getKey();
String value = ClassToString.getClassAsString(entry.getValue());
DH.out(key + " => " + value);
}
}
DH.l();
}
}
@@ -0,0 +1,83 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.application.model.IApplicationService;
import flintstones.helper.debug.DH;
import flintstones.model.ahp.referencepoint.service.IReferencePointService;
import flintstones.model.ahppreferences.service.IProblemPreferencesService;
import flintstones.model.ahpsort.profileassignment.service.IProfileAssignmentService;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.domain.ui.service.IDomainUIService;
import flintstones.model.method.phase.IPhaseMethodService;
import flintstones.model.method.service.IMethodService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.operator.service.IOperatorService;
import flintstones.valuation.ui.service.IValuationUIService;
@SuppressWarnings("javadoc")
public class DumpServicesDebugHandler {
@Inject
IProblemElementService problemService;
@Inject
IDomainService domainService;
@Inject
IDomainUIService uiDomainService;
@Inject
IValuationService valuationService;
@Inject
IValuationUIService valuationUIService;
@Inject
IOperatorService operatorService;
@Inject
IMethodService methodService;
@Inject
IPhaseMethodService phaseService;
@Inject
IApplicationService appService;
@Inject
IProblemPreferencesService ppService;
@Inject
IProfileAssignmentService profileService;
@Inject
IReferencePointService referencePointService;
@Execute
public void execute() {
show(problemService, "problemService");
show(domainService, "domainService");
show(valuationService, "valuationService");
show(appService, "appService");
show(methodService, "methodService");
show(phaseService, "phaseService");
show(ppService, "problemPreferencesService");
show(profileService, "profileService");
show(referencePointService, "referencePointService");
}
private void show(Object service, String name) {
String preText = "========= " + name + " =========\n";
String text = service.toString();
String postText = "\n\n";
DH.out(preText + text + postText);
}
}
@@ -0,0 +1,136 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import flintstones.application.model.IApplicationService;
import flintstones.application.model.ProblemType;
import flintstones.model.ahpsort.profileassignment.service.IProfileAssignmentService;
import flintstones.model.problemelement.service.IProblemElementService;
@SuppressWarnings("javadoc")
public class ExecuteDebugHandler {
@Inject
IEclipseContext context;
@Inject
IProblemElementService problemService;
@Inject
EModelService modelService;
@Inject
MApplication application;
@Inject
EPartService partService;
@Inject
IApplicationService appService;
@Inject
IProfileAssignmentService profileService;
@Execute
public void execute() {
// ahpService.unregister("AHPAlternativeRatingPart");
// ahpService.register("Title",
// "flintstones.domain.ahp",
// "flintstones.application.perspective.gathering.ahp.ui",
// "flintstones.application.perspective.gathering.ahp.ui",
// "AHPAlternativeRatingPart");
//
// ProblemElement[] experts = problemService.getAll(Expert.Type);
// ProblemElement[] crits = problemService.getAll(Criterion.Type);
//
// if(experts.length > 0 && crits.length > 0) {
//
// Expert e = (Expert) experts[0];
// Criterion c = (Criterion) crits[0];
// ProfileAssignment pas = profileService.get(e, c);
//
// BrowserShell shell = new BrowserShell();
// SvgBrowser br = new SvgBrowser(shell.get());
//
// SortingDiagram diagram = new SortingDiagram();
// AHPSortProfile p;
// diagram.setProfiles(pas.getAllProfiles());
// br.setCanvas(diagram);
// shell.setWidget(br);
// br.render();
//
// shell.open();
//
// }
ProblemType type = appService.getProblemType();
type = type.equals(ProblemType.Ranking) ? ProblemType.Sorting : ProblemType.Ranking;
appService.launchProblem(type);
// int x = 0;
//
// BrowserShell shell = new BrowserShell();
//
// SvgChart chart = new SvgChart(1666, 1000, 1, 1);
// SvgBrowser br = new SvgBrowser(shell.get(), chart);
//
// double min = 0.0;
// double max = 1.0;
//
// LineSeries redSeries = new LineSeries();
// for(int i = 0; i < 11; i++) {
//
// Random r = new Random();
// double a = (double)i/10;
// double b = min + (max - min) * r.nextDouble();
//
// redSeries.add(a, b);
//
// }
// redSeries.setColor("#ff0000");
// redSeries.showLegend(true);
// redSeries.showMarkers(true);
//
// // lines
// double[][] points = new double[4][2];
// points[0][0] = .10;
// points[0][1] = .10;
// points[1][0] = .20;
// points[1][1] = .20;
// points[2][0] = .30;
// points[2][1] = .30;
// points[3][0] = .40;
// points[3][1] = .15;
//
// LineSeries series = new LineSeries(points);
// series.setColor("#0000ff");
// series.showLegend(false);
//
// chart.drawLineSeries(series);
// chart.drawLineSeries(redSeries);
// chart.drawMarkers(false, false, 0.1);
//
// shell.setWidget(br);
// br.render();
//
// shell.open();
}
}
@@ -0,0 +1,262 @@
package flintstones.application.debug.handler;
import java.io.FileWriter;
import java.io.IOException;
import javax.inject.Inject;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import flintstones.domain.fuzzyset.FuzzySet;
import flintstones.domain.fuzzyset.function.types.TrapezoidalFunction;
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
import flintstones.domain.numeric.integer.NumericIntegerDomain;
import flintstones.domain.numeric.real.NumericRealDomain;
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.model.domain.service.IDomainService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.valuation.hesitant.HesitantValuation;
import flintstones.valuation.linguistic.LinguisticValuation;
import flintstones.valuation.numeric.integer.IntegerValuation;
import flintstones.valuation.numeric.real.RealValuation;
public class ExportToAFRYCA {
private static final String AFRYCA_INTEGER_DOMAIN = "afryca.domain.integer";
private static final String AFRYCA_REAL_DOMAIN = "afryca.domain.real";
private static final String AFRYCA_LINGUISTIC_DOMAIN = "afryca.domain.fuzzyset";
private static final String AFRYCA_STRUCTURE = "afryca.decisionmatrix";
private static final String[] FILTER_NAMES = { "AFRYCA files (*.afryca)" }; //$NON-NLS-1$
private static final String[] FILTER_EXTS = { "*.afryca" }; //$NON-NLS-1$
private static final String SEMICOLON = ";";
public static final String SEPARATOR = "_SEPARATOR_";
@Inject
IProblemElementService problemService;
@Inject
private IDomainService domainService;
@Inject
private IValuationService valuationService;
@Execute
public void execute() {
try {
export();
} catch (IOException | XMLStreamException e) {
e.printStackTrace();
}
}
private void export() throws IOException, XMLStreamException {
FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
dlg.setFilterNames(FILTER_NAMES);
dlg.setFilterExtensions(FILTER_EXTS);
String fileName = dlg.open();
if(fileName != null)
write(fileName);
}
private void write(String fileName) throws IOException, XMLStreamException {
XMLStreamWriter streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileWriter(fileName));
streamWriter.writeStartElement("gdmp"); //$NON-NLS-1$
streamWriter.writeStartElement("file"); //$NON-NLS-1$
streamWriter.writeEndElement(); //$NON-NLS-1$
writeExperts(streamWriter);
writeCriteria(streamWriter);
writeAlternatives(streamWriter);
writeDomains(streamWriter);
writeStructure(streamWriter);
writePreferences(streamWriter);
writeDomainsStructures(streamWriter);
streamWriter.writeEndElement();
streamWriter.writeEndDocument();
streamWriter.flush();
streamWriter.close();
}
private void writeExperts(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("experts"); //$NON-NLS-1$
for(ProblemElement e: problemService.getSubElements(Expert.Type)) {
streamWriter.writeStartElement("expert");//$NON-NLS-1$
streamWriter.writeCharacters(e.getName());
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
private void writeCriteria(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("criteria"); //$NON-NLS-1$
for(ProblemElement c: problemService.getSubElements(Criterion.Type)) {
streamWriter.writeStartElement("criterion");//$NON-NLS-1$
streamWriter.writeCharacters(c.getName());
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
private void writeAlternatives(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("alternatives"); //$NON-NLS-1$
for(ProblemElement a: problemService.getAll(Alternative.Type)) {
streamWriter.writeStartElement("alternative");
streamWriter.writeCharacters(a.getName());
streamWriter.writeEndElement();
}
streamWriter.writeEndElement(); //$NON-NLS-1$
}
private void writeDomains(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("domains"); //$NON-NLS-1$
for(Domain d: domainService.getAll()) {
streamWriter.writeStartElement("domain");
if(d instanceof NumericIntegerDomain) {
streamWriter.writeCharacters(AFRYCA_INTEGER_DOMAIN);
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.getName());
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.toString());
} else if(d instanceof NumericRealDomain) {
streamWriter.writeCharacters(AFRYCA_REAL_DOMAIN);
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.getName());
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.toString());
} else if(d instanceof FuzzySet) {
streamWriter.writeCharacters(AFRYCA_LINGUISTIC_DOMAIN);
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.getName());
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(toStringLinguisticDomain((FuzzySet) d));
}
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
private String toStringLinguisticDomain(FuzzySet domain) {
String result = ""; //$NON-NLS-1$
int cardinality = domain.getLabelSet().getCardinality();
if(cardinality > 0) {
for(int i = 0; i < cardinality; ++i) {
if(i > 0) {
result += "separator"; //$NON-NLS-1$
}
result += "[" + toStringLabel(domain.getLabelSet().getLabels().get(i)) + ";" + domain.getValues().get(i) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
return result;
}
private String toStringLabel(LabelLinguisticDomain label) {
return label.getName() + ";" + toStringSemantic((TrapezoidalFunction) label.getSemantic());
}
private String toStringSemantic(TrapezoidalFunction semantic) {
return ("Trapezoidal(" + semantic.getLimits()[0] + ", " + semantic.getLimits()[1] + ", " +
semantic.getLimits()[2] + ", " + semantic.getLimits()[3] + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
private void writeStructure(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("structure");
streamWriter.writeCharacters(AFRYCA_STRUCTURE);
streamWriter.writeEndElement();
}
private void writePreferences(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("preferences");
double value;
LabelLinguisticDomain label;
ProblemElement exp, alt, crit;
for(int expert = 0; expert < problemService.getSubElements(Expert.Type).length; ++expert) {
exp = problemService.getSubElements(Expert.Type)[expert];
for(int row = 0; row < problemService.getSubElements(Criterion.Type).length; ++row) {
streamWriter.writeStartElement("preference");
crit = problemService.getSubElements(Criterion.Type)[row];
for(int col = 0; col < problemService.getAll(Alternative.Type).length; ++col) {
alt = problemService.getAll(Alternative.Type)[col];
ProblemElementKey pek = new ProblemElementKey((Expert) exp, (Alternative) alt, (Criterion) crit);
Valuation v = valuationService.getValuationFor(pek);
if(v instanceof IntegerValuation) {
value = ((IntegerValuation) v).getValue();
streamWriter.writeCharacters(Integer.toString((int) value));
} else if(v instanceof RealValuation) {
value = ((RealValuation) v).getValue();
streamWriter.writeCharacters(Double.toString(value));
} else if(v instanceof LinguisticValuation) {
label = ((LinguisticValuation) v).getLabel();
streamWriter.writeCharacters(label.getName());
} else if(v instanceof HesitantValuation) {
streamWriter.writeCharacters(toStringAFRYCA((HesitantValuation) v));
}
if(col != problemService.getAll(Alternative.Type).length - 1)
streamWriter.writeCharacters(",");
}
streamWriter.writeEndElement();
}
}
streamWriter.writeEndElement();
}
public String toStringAFRYCA(HesitantValuation v) {
if (v.isPrimary()) {
return v.getLabel().toString();
} else if (v.isUnary()) {
return (v.getUnaryRelation().toString() + SEPARATOR + v.getTerm()); //$NON-NLS-1$
} else if (v.isBinary()) {
return ("Between" + SEPARATOR + v.getLowerTerm() + SEPARATOR + "and" + SEPARATOR + v.getUpperTerm());
} else {
return " "; //$NON-NLS-1$
}
}
private void writeDomainsStructures(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("domains_structures");
ProblemElement exp, alt, crit;
for(int expert = 0; expert < problemService.getSubElements(Expert.Type).length; ++expert) {
exp = problemService.getSubElements(Expert.Type)[expert];
for(int row = 0; row < problemService.getSubElements(Criterion.Type).length; ++row) {
streamWriter.writeStartElement("domain_structure");
crit = problemService.getSubElements(Criterion.Type)[row];
for(int col = 0; col < problemService.getAll(Alternative.Type).length; ++col) {
alt = problemService.getAll(Alternative.Type)[col];
ProblemElementKey pek = new ProblemElementKey((Expert) exp, (Alternative) alt, (Criterion) crit);
Valuation v = valuationService.getValuationFor(pek);
streamWriter.writeCharacters(v.getDomain().getName());
if(col != problemService.getAll(Alternative.Type).length - 1)
streamWriter.writeCharacters("separator");
}
streamWriter.writeEndElement();
}
}
streamWriter.writeEndElement();
}
}
@@ -0,0 +1,25 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.services.events.IEventBroker;
import flintstones.entity.method.phase.ui.PhaseMethodUI;
import flintstones.model.method.phase.IPhaseMethodService;
@SuppressWarnings("javadoc")
public class FillOperatorsAggregation {
@Inject
IPhaseMethodService phaseService;
@Inject
IEventBroker broker;
@Execute
public void execute() {
System.err.println("Hay que rehacerlo");
broker.post(PhaseMethodUI.REFRESH_SUB_ID, null);
}
}
@@ -0,0 +1,87 @@
package flintstones.application.debug.handler;
import java.util.Arrays;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.services.events.IEventBroker;
import flintstones.application.constants.FrameworkConstants;
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.model.method.phase.IPhaseMethodService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.valuation.service.IValuationService;
@SuppressWarnings("javadoc")
public class FillValuationsDebugHandler {
@Inject
IPhaseMethodService phaseService;
@Inject
IEventBroker broker;
@Inject
IProblemElementService problemService;
@Inject
IValuationService valuationService;
Valuation[] valuations;
@Execute
public void execute() {
fill();
sendEvents();
}
private void fill() {
valuations = Arrays.stream(valuationService.getAll()).filter( k -> k.isEvaluated()).toArray(Valuation[]::new);
ProblemElement[] criterions = problemService.getSubElements(Criterion.Type);
ProblemElement[] experts = problemService.getSubElements(Expert.Type);
ProblemElement[] alternatives = problemService.getAll(Alternative.Type);
fillValuations(criterions, experts, alternatives);
}
private void fillValuations(ProblemElement[] cs, ProblemElement[] es, ProblemElement[] as) {
for(ProblemElement c : cs )
for(ProblemElement e : es )
for(ProblemElement a : as ) {
ProblemElementKey pek = new ProblemElementKey((Expert)e, (Alternative)a, (Criterion)c);
if(valuationService.getValuationFor( pek ) == null || !valuationService.getValuationFor(pek).isEvaluated() )
fillWithRandomValuation(c,e,a);
}
}
private void fillWithRandomValuation(ProblemElement c, ProblemElement e, ProblemElement a) {
if(valuations.length == 0)
throw new RuntimeException("Es necesario tener al menos 1 evaluación puesta. Se elige al azar entre las disponibles");
int rnd = (int) (Math.random() * valuations.length) + 1;
Valuation v = valuations[rnd-1];
ProblemElementKey pek = new ProblemElementKey((Expert)e, (Alternative)a, (Criterion)c);
valuationService.addOrUpdate(pek, v);
}
private void sendEvents() {
this.broker.post(FrameworkConstants.TOPIC_FRAMEWORK_PROBLEMELEMENT_CREATED, FrameworkConstants.empty() );
this.broker.post(FrameworkConstants.TOPIC_FRAMEWORK_DOMAIN_CREATED, null);
this.broker.post(FrameworkConstants.TOPIC_VALUATION_CREATED, null);
}
}
@@ -0,0 +1,31 @@
package flintstones.application.debug.handler;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.application.model.IApplicationService;
@SuppressWarnings("javadoc")
public class OpenSaveFileDebugHandler {
@Inject
IApplicationService appService;
@Execute
public void execute() {
String fileName = appService.getSavePath();
File f = new File(fileName);
try {
Desktop.getDesktop().open(f);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,117 @@
package flintstones.application.debug.handler;
import java.lang.reflect.Field;
import java.util.HashMap;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MParameter;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import flintstones.application.constants.ApplicationContants;
import flintstones.application.constants.FrameworkConstants;
import flintstones.helper.data.Pair;
import flintstones.helper.data.PairList;
import flintstones.helper.debug.DH;
@SuppressWarnings("javadoc")
public class SendBrokerDebugHandler {
@Inject
IEventBroker broker;
@Inject
MApplication application;
@Inject
EModelService modelService;
@Inject
MApplication app;
MMenu menu;
@Execute
public void execute(@Optional ParameterizedCommand command) {
@SuppressWarnings("unchecked")
HashMap<String, String> map = (HashMap<String, String>) command.getParameterMap();
String eventID = map.get(ApplicationContants.MParameter_General_Sendbroker);
// Change selected method
DH.out("Lanzado evento " + eventID);
broker.send(eventID, null);
}
@PostConstruct
private void postConstruct() {
buildMenu();
}
private void buildMenu() {
String commandId = ApplicationContants.MCommand_General_Sendbroker;
String menuId = ApplicationContants.MMenu_Sendbroker;
String windowId = ApplicationContants.MWindow_Main;
MWindow window = (MWindow) this.modelService.find(windowId, this.application);
MCommand command = modelService.findElements(app, commandId, MCommand.class, null).get(0);
MMenu mainMenu = window.getMainMenu();
menu = (MMenu) mainMenu.getChildren().stream().filter(k -> k.getElementId().equals(menuId)).findFirst().get();
PairList<String,String> events = getEvents();
for(Pair<String, String> event : events ) {
MHandledMenuItem menuItem = modelService.createModelElement(MHandledMenuItem.class);
MParameter parameter = modelService.createModelElement(MParameter.class);
menuItem.setLabel(event.getLeft());
menuItem.setCommand(command);
parameter.setName(ApplicationContants.MParameter_General_Sendbroker);
parameter.setValue(event.getRight());
menuItem.getParameters().add(parameter);
menu.getChildren().add(menuItem);
}
}
private PairList<String,String> getEvents(){
PairList<String,String> pairlist = new PairList<>();
Field[] fields = FrameworkConstants.class.getFields();
for(Field f : fields) {
try {
String name = f.getName();
String value = (String)f.get(null);
name = name.replaceAll("TOPIC_", "");
pairlist.put(name, value);
// System.out.println(name + " -> " + value );
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
return pairlist;
}
}
@@ -0,0 +1,14 @@
package flintstones.application.debug.handler;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.helper.data.text.DebugStream;
@SuppressWarnings("javadoc")
public class SystemOutDebugHandler {
@Execute
private void execute() {
DebugStream.activate();
}
}
@@ -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>
@@ -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.application.perspective.documentation.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.application.perspective.documentation.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>1779484362526</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>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -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
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,20 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: flintstones.application.perspective.documentation.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.e4.ui.model.workbench,
org.eclipse.e4.core.di,
org.eclipse.e4.core.contexts,
flintstones.application,
org.eclipse.e4.core.services,
flintstones.model.ui.service,
org.eclipse.jface,
flintstones.application.constants,
org.eclipse.e4.ui.di,
flintstones.helper.html,
flintstones.helper.data,
javax.annotation
Automatic-Module-Name: flintstones.application.perspective.documentation.ui
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: javax.inject;version="1.0.0"
@@ -0,0 +1,6 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
fragment.e4xmi,\
plugin.xml
source.. = src/
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="ASCII"?>
<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="_p4uAAB78Eemjkpq3ZNFQaA">
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_p4uAAh78Eemjkpq3ZNFQaA" featurename="handlers" parentElementId="flintstones.application.application">
<elements xsi:type="commands:Handler" xmi:id="_p4uAAx78Eemjkpq3ZNFQaA" elementId="flintstones.application.handler.documentation" contributionURI="bundleclass://flintstones.application.perspective.documentation.ui/flintstones.application.perspective.documentation.ui.handler.DocumentationHandler" command="_rsQaMR78Eemjkpq3ZNFQaA"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_rsQaMB78Eemjkpq3ZNFQaA" featurename="commands" parentElementId="flintstones.application.application">
<elements xsi:type="commands:Command" xmi:id="_rsQaMR78Eemjkpq3ZNFQaA" elementId="flintstones.application.command.documentation" commandName="Documentaci&#xf3;n"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_ue79MB78Eemjkpq3ZNFQaA" featurename="children" parentElementId="flintstones.application.menu.main">
<elements xsi:type="menu:HandledMenuItem" xmi:id="_ue79MR78Eemjkpq3ZNFQaA" elementId="flintstones.application.handledmenuitem.documentation" visible="false" label="Documentaci&#xf3;n" command="_rsQaMR78Eemjkpq3ZNFQaA"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_-EYoEB78Eemjkpq3ZNFQaA" featurename="children" parentElementId="flintstones.application.perspectivestack.modes">
<elements xsi:type="advanced:Perspective" xmi:id="_-EYoER78Eemjkpq3ZNFQaA" elementId="flintstones.application.perspective.documentation" label="Documentaci&#xf3;n">
<children xsi:type="basic:PartSashContainer" xmi:id="_reIpMB79Eemjkpq3ZNFQaA" elementId="flintstones.application.perspective.documentation.ui.partsashcontainer.0" horizontal="true">
<children xsi:type="basic:Part" xmi:id="_te_GoB79Eemjkpq3ZNFQaA" elementId="flintstones.application.perspective.documentation.ui.part.0" contributionURI="bundleclass://flintstones.application.perspective.documentation.ui/flintstones.application.perspective.documentation.ui.DocumentationSelectorPart"/>
<children xsi:type="basic:Part" xmi:id="_t0k8IB79Eemjkpq3ZNFQaA" elementId="flintstones.application.perspective.documentation.ui.part.1" visible="false" contributionURI="bundleclass://flintstones.application.perspective.documentation.ui/flintstones.application.perspective.documentation.ui.DocumentationInformation"/>
</children>
</elements>
</fragments>
</fragment:ModelFragments>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<extension
id="flintstones.application.perspective.documentation.ui.fragment"
point="org.eclipse.e4.workbench.model">
<fragment
uri="fragment.e4xmi">
</fragment>
</extension>
</plugin>
@@ -0,0 +1,87 @@
package flintstones.application.perspective.documentation.ui;
import java.io.IOException;
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.ui.di.UIEventTopic;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import flintstones.application.constants.FrameworkConstants;
import flintstones.helper.FileHelper;
import flintstones.helper.html.HtmlMarkdown;
import flintstones.model.ui.service.UiService;
public class DocumentationInformation {
@Inject
IEclipseContext context;
@Inject
IEventBroker broker;
@Inject
MPart part;
Composite markdownBase;
@PostConstruct
public void init(Composite parent) {
UiService.setGridLayout(parent, 1);
UiService.setGridData(parent, 9, 9, true, true);
markdownBase = new Composite(parent,SWT.BORDER);
UiService.setGridLayout(markdownBase, 1);
UiService.setGridData(markdownBase, 9, 9, true, true);
}
private void draw(String path) {
// FaqHelper faq = ContextInjectionFactory.make(FaqHelper.class, context);
String content = null;
try {
content = FileHelper.readFile(path);
} catch (IOException e) {
e.printStackTrace();
}
HtmlMarkdown markdownViewer = new HtmlMarkdown(markdownBase);
markdownViewer.setFile(content);
markdownViewer.render();
part.setVisible(true);
}
private void hide() {
part.setVisible(false);
}
/**
* Subscribe.
*
* @param event the event
*/
@Inject
@Optional
private void subscribe(@UIEventTopic(FrameworkConstants.TOPIC_SELECTION_DOCUMENTATION) String path) {
if( path != null )
draw(path);
else
hide();
}
}
@@ -0,0 +1,90 @@
package flintstones.application.perspective.documentation.ui;
import java.io.File;
import java.text.DateFormat;
import java.util.Arrays;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import flintstones.application.constants.FrameworkConstants;
import flintstones.application.perspective.documentation.ui.provider.FileModifiedLabelProvider;
import flintstones.application.perspective.documentation.ui.provider.ViewContentProvider;
import flintstones.application.perspective.documentation.ui.provider.ViewLabelProvider;
import flintstones.model.ui.service.UiService;
public class DocumentationSelectorPart {
@Inject
IEclipseContext context;
@Inject
IEventBroker broker;
TreeViewer viewer;
private static final DateFormat dateFormat = DateFormat.getDateInstance();
@PostConstruct
public void init(Composite parent) {
viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ViewContentProvider());
viewer.getTree().setHeaderVisible(true);
TreeViewerColumn mainColumn = new TreeViewerColumn(viewer, SWT.NONE);
mainColumn.getColumn().setText("Name");
mainColumn.getColumn().setWidth(300);
mainColumn.setLabelProvider(new DelegatingStyledCellLabelProvider(new ViewLabelProvider(UiService.getImage("new.png"))));
TreeViewerColumn modifiedColumn = new TreeViewerColumn(viewer, SWT.NONE);
modifiedColumn.getColumn().setText("Last Modified");
modifiedColumn.getColumn().setWidth(100);
modifiedColumn.getColumn().setAlignment(SWT.RIGHT);
modifiedColumn.setLabelProvider(new DelegatingStyledCellLabelProvider(new FileModifiedLabelProvider(dateFormat)));
File folder = new File("C:\\Users\\igmunoz\\Desktop\\wiki");
File[] files = Arrays.stream(folder.listFiles()).filter(k -> k.getName().contains(".md")).toArray(File[]::new);
viewer.setInput(files);
// parent.addControlListener(new ControlAdapter() {
// @Override
// public void controlResized(ControlEvent e) {
// Composite composite = (Composite) e.widget;
// int width = composite.getBounds().width;
// mainColumn.getColumn().setWidth(width);
// }
// });
Tree tree = (Tree) viewer.getControl();
tree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem item = (TreeItem) e.item;
File file = (File) item.getData();
String path = file.getAbsolutePath();
broker.send(FrameworkConstants.TOPIC_SELECTION_DOCUMENTATION, path);
}
});
}
}

Some files were not shown because too many files have changed in this diff Show More