Buenos días Rubén.
Te pedía la sentencia CREATE TABLE para confirmar el tipo de datos del
campo donde está almacenado el hiperenlace.
Te adjunto la clase del diálogo de configuración del hiperenlace con el
cambio introducido para que admita este tipo de campos como campo de
hiperenlace. En el método "createSimplePanel()", línea 204, tienes el
cambio que he introducido.
Cualquier duda al respecto ya me comentas.
Un cordial saludo,
Rubén Sanabrias escribió:
Hola, Sergio.
Las sentencias SQL para definir la tabla son:
CREATE TABLE "public"."_foto_modelo"(
"foto" varchar(100) ,
"gid" int4 NOT NULL ,
"modelo" varchar(15) ,
"geometry" geometry ,
PRIMARY KEY ("gid")
) WITHOUT OIDS;
CREATE INDEX "ndx_modelos_geometry" ON "public"."_foto_modelo" USING
gist ("geometry");
No se que buscas.
Pero porsiaca añado que lo he probado en otras tablas con nombres
distintos, por si era por tener un "_" delante.
Vete a saber, cosas más raras se ven todos los días. :)
Gracias por tu pronta respuesta.
Un saludo.
2009/3/5 Sergio Baños Calvo <[email protected] <mailto:[email protected]>>
Buenas tardes Rubén.
¿Puedes enviarme la sentencia CREATE TABLE de tu capa de
hiperenlaces? Creo tener detectado el problema pero necesito
confirmarlo antes de poder indicarte cualquier solución al respecto.
Un cordial saludo,
Rubén Sanabrias escribió:
Hola.
Desde que la versión 1.2.1 de Kosmo me he encontrado con el
problema de que los hipervínculos no se pueden configurar en
capas PostGis (no se si exclusivamente en este tipo de capas,
pero he observado que con shp sí que funciona).
El problema es que en el diálogo de config de hiperenlace la
lista de atributos de la capa aparece vacía.
Adjunto captura de un ejemplo en que se puede ver que la capa
tiene atributos (está abierta la ventana de tabla de
atributos) pero que en el diálogo de hiperenlace aparece la
lista de atributos en blanco.
También copio aquí el log de kosmo.
Me llama la atención la última línea, pero la capa tiene clave
primaria definida en la BD (gid) de tipo numérico (int4) y el
usuario con que se accede tiene permisos suficientes para
hacer de todo.
05/03/2009 12:32:34 INFO JUMPWorkbench:334 - Iniciando la
aplicación Kosmo - Sistema Abierto de Información
Geográfica 1.2.1
(20081021) - 05-mar-2009 12:32:34
05/03/2009 12:32:34 INFO JUMPWorkbench:340 - Versión de Java :
1.6.0_11
05/03/2009 12:32:34 INFO JUMPWorkbench:342 - SO : Windows
Vista (6.0)
05/03/2009 12:32:34 INFO JUMPWorkbench:484 - Usando L&F
com.sun.java.swing.plaf.windows.WindowsLookAndFeel
05/03/2009 12:32:46 INFO DataBaseConnectionFactory:131 -
Connexió
creada per a *************
05/03/2009 12:34:25 WARN AbstractJDBCDataSource:1504 - No
se ha
encontrado ninguna clave para la tabla _foto_modelo
El hiperenlace era una función muy importante para nosotros y
nos es vital que vuelva a funcionar.
Ruego que si conocen una solución al problema nos indiquen
cómo solventarlo sin tener que esperar a una próxima versión
(no nos importa modificar nosotros mismos el código).
Gracias. :)
--
-----------------------------------------------------------
Rubén Sanabrias
Sent from: Alicante Comunidad Valenciana España.
------------------------------------------------------------------------
------------------------------------------------------------------------
_______________________________________________
Kosmo mailing list
[email protected] <mailto:[email protected]>
http://lists.saig.es/mailman/listinfo/kosmo
--
Sergio Baños Calvo
Jefe de desarrollos
Sistemas Abiertos de Información Geográfica, S.L. (SAIG S.L.)
Tlfno. móvil: 685005960
Tlfno. fijo: (+34) 954788876
E-mail: [email protected] <mailto:[email protected]>
_______________________________________________
Kosmo mailing list
[email protected] <mailto:[email protected]>
http://lists.saig.es/mailman/listinfo/kosmo
--
-----------------------------------------------------------
Rubén Sanabrias
------------------------------------------------------------------------
_______________________________________________
Kosmo mailing list
[email protected]
http://lists.saig.es/mailman/listinfo/kosmo
--
Sergio Baños Calvo
Jefe de desarrollos
Sistemas Abiertos de Información Geográfica, S.L. (SAIG S.L.)
Tlfno. móvil: 685005960
Tlfno. fijo: (+34) 954788876
E-mail: [email protected]
/*
* Kosmo - Sistema Abierto de Información Geográfica
* Kosmo - Open Geographical Information System
*
* http://www.saig.es
* (C) 2006, SAIG S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
*
* For more information, contact:
*
* Sistemas Abiertos de Información Geográfica, S.L.
* Avnda. República Argentina, 28
* Edificio Domocenter Planta 2ª Oficina 7
* C.P.: 41930 - Bormujos (Sevilla)
* España / Spain
*
* Teléfono / Phone Number
* +34 954 788876
*
* Correo electrónico / Email
* [email protected]
*
*/
package org.saig.jump.widgets.hiperlink;
import java.awt.CardLayout;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.saig.core.gui.swing.sldeditor.util.FormUtils;
import org.saig.core.model.data.Table;
import org.saig.core.model.feature.Attribute;
import org.saig.jump.lang.I18N;
import com.vividsolutions.jump.feature.AttributeType;
import com.vividsolutions.jump.feature.FeatureSchema;
import com.vividsolutions.jump.feature.HiperLink;
import com.vividsolutions.jump.feature.HiperLinkCompound;
import com.vividsolutions.jump.workbench.WorkbenchContext;
import com.vividsolutions.jump.workbench.model.Layer;
import com.vividsolutions.jump.workbench.model.Layerable;
import com.vividsolutions.jump.workbench.ui.GUIUtil;
import com.vividsolutions.jump.workbench.ui.OKCancelPanel;
/**
*
*
* <p>
*
* </p>
* @author
* @since 1.0.0
*/
public class HiperLinkConfigurationDialog extends JDialog {
private static final int HIPERLINK_SIMPLE = 0;
private static final int HIPERLINK_COMPOUND = 1;
private int hiperLinkType = HIPERLINK_SIMPLE;
private WorkbenchContext context;
private JPanel cardPanel;
private JComboBox sourceHiperLinkFieldComboBox;
private JComboBox sourceKeysFieldComboBox;
private JComboBox tableComboBox;
private JComboBox descriptionFieldTableComboBox;
private JComboBox fieldTargetKeysComboBox;
private JComboBox targetHiperLinkFieldComboBox;
private JComboBox descriptionHiperLinkFieldComboBox;
private JCheckBox simple,compound;
private JButton desactivarJButton = new
JButton(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.Off"));
//$NON-NLS-1$
private boolean deactivate = false;
private Layer layer;
private boolean exitOk = false;
private static final String NO_DESCRIPTION_VALUE = "---------";
//$NON-NLS-1$
public HiperLinkConfigurationDialog(JFrame parent,
WorkbenchContext context, boolean modal, HiperLink
hiperlink) {
super(parent, modal);
this.context = context;
setTitle(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.hiperlink-configuration"));
//$NON-NLS-1$
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new GridBagLayout());
Layerable[] layers =
context.getLayerNamePanel().getSelectedLayers();
if (layers != null)
layer = (Layer) layers[0];
JPanel selectorPanel = createSelectorPanel(hiperlink);
cardPanel = createCardLayoutPanel(hiperlink);
OKCancelPanel okCancelPanel = createOKcancelPanel();
okCancelPanel.add(desactivarJButton);
desactivarJButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
deactivate = true;
exitOk = true;
setVisible(false);
}
});
FormUtils.addRowInGBL(mainPanel, 0, 0, selectorPanel);
FormUtils.addRowInGBL(mainPanel, 1, 0, cardPanel);
FormUtils.addRowInGBL(mainPanel, 2, 0, okCancelPanel);
setContentPane(mainPanel);
pack();
if (hiperlink instanceof HiperLinkCompound){
compound.setSelected(true);
compound.getActionListeners()[0].actionPerformed(null);
} else {
simple.setSelected(true);
}
GUIUtil.centreOnScreen(this);
setVisible(true);
}
private JPanel createSelectorPanel(HiperLink hiperlink) {
JPanel selectorPanel = new JPanel();
selectorPanel.setLayout(new GridBagLayout());
selectorPanel.setBorder(BorderFactory
.createTitledBorder(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.hiperlink-type")));
//$NON-NLS-1$
ButtonGroup agrupacion = new ButtonGroup();
simple = new
JCheckBox(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.basic-hiperlink"));
//$NON-NLS-1$
simple.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
CardLayout cl = (CardLayout)
(cardPanel.getLayout());
cl.show(cardPanel, "SIMPLE"); //$NON-NLS-1$
hiperLinkType = HIPERLINK_SIMPLE;
}
});
compound = new
JCheckBox(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.compound-hiperlink"));
//$NON-NLS-1$
compound.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
CardLayout cl = (CardLayout)
(cardPanel.getLayout());
cl.show(cardPanel, "COMPOUND"); //$NON-NLS-1$
hiperLinkType = HIPERLINK_COMPOUND;
}
});
if (context.getDataManager().size() == 0){
compound.setEnabled(false);
}
agrupacion.add(simple);
agrupacion.add(compound);
simple.setSelected(true);
FormUtils.addRowInGBL(selectorPanel, 0, 0, simple);
FormUtils.addRowInGBL(selectorPanel, 1, 0, compound);
return selectorPanel;
}
private JPanel createSimplePanel(HiperLink hiperlink) {
JPanel simplePanel = new JPanel();
simplePanel.setLayout(new GridBagLayout());
FeatureSchema schema = layer.getFeatureSchema();
List attributeNames = new ArrayList();
for (int i = 0; i < schema.getAttributeCount(); i++) {
Attribute element = schema.getAttribute(i);
if
(element.getType().toJavaClass().equals(String.class) &&
!element.isPrimaryKey()) {
attributeNames.add(element.getName());
}
}
Collections.sort(attributeNames);
sourceHiperLinkFieldComboBox = new JComboBox(attributeNames.toArray());
attributeNames.add(NO_DESCRIPTION_VALUE);
Collections.sort(attributeNames);
descriptionHiperLinkFieldComboBox = new
JComboBox(attributeNames.toArray());
JLabel hiperLinkLabel =
new
JLabel(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.hiperlink-field")
+ " :"); //$NON-NLS-1$ //$NON-NLS-2$
FormUtils.addRowInGBL(simplePanel, 0, 0, hiperLinkLabel,
sourceHiperLinkFieldComboBox);
JLabel descriptionLabel
= new
JLabel(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.Description-field")
+ " :"); //$NON-NLS-1$ //$NON-NLS-2$
FormUtils.addRowInGBL(simplePanel,1,0,descriptionLabel,
descriptionHiperLinkFieldComboBox);
FormUtils.addFiller(simplePanel,2,0);
if (hiperlink!=null){
sourceHiperLinkFieldComboBox.setSelectedItem(hiperlink.getFieldWithHiperLink());
descriptionHiperLinkFieldComboBox.setSelectedItem(hiperlink.getFieldDescription());
}
return simplePanel;
}
private JPanel createCompoundPanel(HiperLink hiperlink) {
JPanel compoundPanel = new JPanel();
compoundPanel.setLayout(new GridBagLayout());
JLabel sourceKeyLabel = new
JLabel(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.layer-key-field")
+ " :"); //$NON-NLS-1$ //$NON-NLS-2$
fieldTargetKeysComboBox = new JComboBox();
targetHiperLinkFieldComboBox = new JComboBox();
descriptionFieldTableComboBox = new JComboBox();
FeatureSchema layerSchema = layer.getFeatureSchema();
List attributeNames = new ArrayList();
for (int i = 0; i < layerSchema.getAttributeCount(); i++) {
Attribute element = layerSchema.getAttribute(i);
if (!element.getType().equals(AttributeType.GEOMETRY)) {
attributeNames.add(element.getName());
}
}
Collections.sort(attributeNames);
sourceKeysFieldComboBox = new
JComboBox(attributeNames.toArray());
FormUtils.addRowInGBL(compoundPanel, 0, 0, sourceKeyLabel,
sourceKeysFieldComboBox);
JLabel tableLabel = new
JLabel(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.table")
+ " :"); //$NON-NLS-1$ //$NON-NLS-2$
// Obtenemos todas las tablas con las que podemos enganchar
List tables = context.getDataManager().getRealTables();
tableComboBox = new JComboBox(tables.toArray());
tableComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Table selectedTable = (Table) tableComboBox
.getSelectedItem();
FeatureSchema schema =
selectedTable.getSchema();
List validFieldTargetKeysAttrNames = new ArrayList();
List validTargetHiperLinkFieldAttrNames = new ArrayList();
for (int i = 0; i < schema.getAttributeCount();
i++) {
Attribute element =
schema.getAttribute(i);
if
(!element.getType().equals(AttributeType.GEOMETRY)) {
validFieldTargetKeysAttrNames.add(element.getName());
}
if
(element.getType().toJavaClass().equals(String.class)) {
validTargetHiperLinkFieldAttrNames.add(element.getName());
}
}
Collections.sort(validFieldTargetKeysAttrNames);
Collections.sort(validTargetHiperLinkFieldAttrNames);
fieldTargetKeysComboBox.removeAllItems();
descriptionFieldTableComboBox.removeAllItems();
descriptionFieldTableComboBox.addItem(NO_DESCRIPTION_VALUE);
for( Iterator iter = validFieldTargetKeysAttrNames.iterator();
iter.hasNext(); ) {
String name = (String) iter.next();
fieldTargetKeysComboBox.addItem(name);
descriptionFieldTableComboBox.addItem(name);
}
targetHiperLinkFieldComboBox.removeAllItems();
for( Iterator iter =
validTargetHiperLinkFieldAttrNames.iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
targetHiperLinkFieldComboBox.addItem(name);
}
}
});
if (tables.size() > 0) {
Table selectedTable = (Table) tables.get(0);
FeatureSchema tableSchema = selectedTable.getSchema();
List validFieldTargetKeysAttrNames = new ArrayList();
List validTargetHiperLinkFieldAttrNames = new ArrayList();
for (int i = 0; i < tableSchema.getAttributeCount(); i++) {
Attribute element = tableSchema.getAttribute(i);
if (!element.getType().equals(AttributeType.GEOMETRY)) {
validFieldTargetKeysAttrNames.add(element.getName());
}
if (element.getType().toJavaClass().equals(String.class)) {
validTargetHiperLinkFieldAttrNames.add(element.getName());
}
}
Collections.sort(validFieldTargetKeysAttrNames);
Collections.sort(validTargetHiperLinkFieldAttrNames);
fieldTargetKeysComboBox = new
JComboBox(validFieldTargetKeysAttrNames.toArray());
targetHiperLinkFieldComboBox = new
JComboBox(validTargetHiperLinkFieldAttrNames.toArray());
validTargetHiperLinkFieldAttrNames.add(NO_DESCRIPTION_VALUE);
Collections.sort(validTargetHiperLinkFieldAttrNames);
descriptionFieldTableComboBox = new
JComboBox(validTargetHiperLinkFieldAttrNames.toArray());
}
FormUtils.addRowInGBL(compoundPanel, 1, 0, tableLabel,
tableComboBox);
JLabel fieldTargetKeyLabel = new
JLabel(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.table-key-field")
+ " :"); //$NON-NLS-1$ //$NON-NLS-2$
FormUtils.addRowInGBL(compoundPanel, 2, 0, fieldTargetKeyLabel,
fieldTargetKeysComboBox);
JLabel hiperLinkLabel = new
JLabel(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.hiperlink-field")
+ " :"); //$NON-NLS-1$ //$NON-NLS-2$
FormUtils.addRowInGBL(compoundPanel, 3, 0, hiperLinkLabel,
targetHiperLinkFieldComboBox);
JLabel descrptionLabel = new
JLabel(I18N.getString("org.saig.jump.widgets.hiperlink.HiperLinkConfigurationDialog.Description-field")
+ " :"); //$NON-NLS-1$ //$NON-NLS-2$
FormUtils.addRowInGBL(compoundPanel,4,0,descrptionLabel,descriptionFieldTableComboBox);
if (hiperlink != null){
if (hiperlink instanceof HiperLinkCompound){
HiperLinkCompound hc =
(HiperLinkCompound)hiperlink;
fieldTargetKeysComboBox.setSelectedItem(hc.getKeyFieldTarget());
targetHiperLinkFieldComboBox.setSelectedItem(hc.getFieldWithHiperLink());
descriptionFieldTableComboBox.setSelectedItem(hc.getFieldDescription());
sourceHiperLinkFieldComboBox.setSelectedItem(hc.getKeyFieldSource());
sourceKeysFieldComboBox.setSelectedItem(hc.getKeyFieldSource());
}
}
return compoundPanel;
}
private JPanel createCardLayoutPanel(HiperLink hiperlink) {
cardPanel = new JPanel();
cardPanel.setLayout(new CardLayout());
cardPanel.add(createSimplePanel(hiperlink), "SIMPLE");
//$NON-NLS-1$
cardPanel.add(createCompoundPanel(hiperlink), "COMPOUND");
//$NON-NLS-1$
return cardPanel;
}
private OKCancelPanel createOKcancelPanel() {
final OKCancelPanel okCancelPanel = new OKCancelPanel();
GridBagLayout gbPaneOKCancel = new GridBagLayout();
okCancelPanel.setLayout(gbPaneOKCancel);
okCancelPanel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (okCancelPanel.wasOKPressed()) {
exitOk = true;
} else {
exitOk = false;
}
setVisible(false);
}
});
return okCancelPanel;
}
public boolean isOk() {
return exitOk;
}
public HiperLink getHiperLink() {
if (deactivate)
return null;
HiperLink hiperLink = null;
switch (hiperLinkType) {
case HIPERLINK_SIMPLE:
if (sourceHiperLinkFieldComboBox
.getSelectedItem() == null ||((String)
sourceHiperLinkFieldComboBox
.getSelectedItem()).equals("")) {
//$NON-NLS-1$
return null;
}
String descriptionFieldValue = (String)
descriptionHiperLinkFieldComboBox.getSelectedItem();
if (descriptionFieldValue == NO_DESCRIPTION_VALUE)
descriptionFieldValue = null;
hiperLink = new HiperLink((String)
sourceHiperLinkFieldComboBox
.getSelectedItem());
hiperLink.setFieldDescription(descriptionFieldValue);
break;
case HIPERLINK_COMPOUND:
if (targetHiperLinkFieldComboBox.getSelectedItem() ==
null ||
((String)
targetHiperLinkFieldComboBox.getSelectedItem()).equals("")){ //$NON-NLS-1$
return null;
}
String descriptionTableFieldValue =
(String)
descriptionFieldTableComboBox.getSelectedItem();
if (descriptionTableFieldValue == NO_DESCRIPTION_VALUE)
descriptionTableFieldValue = null;
HiperLinkCompound compound = new HiperLinkCompound(
(String)
targetHiperLinkFieldComboBox.getSelectedItem(),
(String)
sourceKeysFieldComboBox.getSelectedItem(),
(String)
fieldTargetKeysComboBox.getSelectedItem());
compound.setFieldDescription(descriptionTableFieldValue);
compound.setTable((Table)
tableComboBox.getSelectedItem());
hiperLink = compound;
break;
default:
break;
}
return hiperLink;
}
public Layer getLayer() {
return this.layer;
}
}
_______________________________________________
Kosmo mailing list
[email protected]
http://lists.saig.es/mailman/listinfo/kosmo