Revision 46251 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/featurequery/DefaultFeatureQueryCalculatedColumnsPanel.java
DefaultFeatureQueryCalculatedColumnsPanel.java | ||
---|---|---|
52 | 52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
53 | 53 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
54 | 54 |
import org.gvsig.tools.swing.api.pickercontroller.DataTypePickerController; |
55 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
55 | 56 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
56 | 57 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
57 | 58 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
... | ... | |
68 | 69 |
extends DefaultFeatureQueryCalculatedColumnsPanelView |
69 | 70 |
implements FeatureQueryCalculatedColumnsPanel { |
70 | 71 |
|
71 |
private class AttributeListElement extends ListElement { |
|
72 |
private class AttributeListElement extends ListElement<FeatureAttributeDescriptor> {
|
|
72 | 73 |
|
73 | 74 |
public AttributeListElement(FeatureAttributeDescriptor value) { |
74 | 75 |
super(value.getLabel(), value); |
... | ... | |
693 | 694 |
} |
694 | 695 |
|
695 | 696 |
private void doRemove() { |
697 |
AttributeListElement selectedValue = (AttributeListElement) this.lstAttributes.getSelectedValue(); |
|
698 |
if( selectedValue == null ) { |
|
699 |
return; |
|
700 |
} |
|
701 |
FeatureAttributeDescriptor attr = selectedValue.getValue(); |
|
702 |
if( attr == null ) { |
|
703 |
return; |
|
704 |
} |
|
705 |
boolean removeFromAggregateFunctions = false; |
|
706 |
boolean removeFromOrder = false; |
|
707 |
boolean removeFromGroupByColums = false; |
|
708 |
if( this.query.getAggregateFunctions().containsKey(attr.getName()) ) { |
|
709 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
710 |
int n = dialogs.confirmDialog( |
|
711 |
"El campo '"+attr.getName()+"' se esta usando en una funcion de agregado. ? Dese borrarlo igualmente ?", |
|
712 |
"Eliminar campo", |
|
713 |
JOptionPane.YES_NO_OPTION, |
|
714 |
JOptionPane.QUESTION_MESSAGE, |
|
715 |
"_FeatureQueryCalculatedColumns_remove_used_column" |
|
716 |
); |
|
717 |
if( n != JOptionPane.YES_OPTION ) { |
|
718 |
return; |
|
719 |
} |
|
720 |
n = dialogs.confirmDialog( |
|
721 |
"? Desea eliminar la funcion de agregado donde se esta usando el campo '"+attr.getName()+"' ?", |
|
722 |
"Eliminar campo", |
|
723 |
JOptionPane.YES_NO_OPTION, |
|
724 |
JOptionPane.QUESTION_MESSAGE, |
|
725 |
"_FeatureQueryCalculatedColumns_remove_aggregate_function_when_remove_column" |
|
726 |
); |
|
727 |
if( n == JOptionPane.YES_OPTION ) { |
|
728 |
removeFromAggregateFunctions = true; |
|
729 |
} |
|
730 |
} |
|
731 |
if( this.query.getGroupByColumns().contains(attr.getName()) ) { |
|
732 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
733 |
int n = dialogs.confirmDialog( |
|
734 |
"El campo '"+attr.getName()+"' se esta usando como campo de agrupacion. ? Dese borrarlo igualmente ?", |
|
735 |
"Eliminar campo", |
|
736 |
JOptionPane.YES_NO_OPTION, |
|
737 |
JOptionPane.QUESTION_MESSAGE, |
|
738 |
"_FeatureQueryCalculatedColumns_remove_used_column" |
|
739 |
); |
|
740 |
if( n != JOptionPane.YES_OPTION ) { |
|
741 |
return; |
|
742 |
} |
|
743 |
n = dialogs.confirmDialog( |
|
744 |
"? Desea eliminar la agrupacion por el campo '"+attr.getName()+"' ?", |
|
745 |
"Eliminar campo", |
|
746 |
JOptionPane.YES_NO_OPTION, |
|
747 |
JOptionPane.QUESTION_MESSAGE, |
|
748 |
"_FeatureQueryCalculatedColumns_remove_group_by_column_when_remove_column" |
|
749 |
); |
|
750 |
if( n == JOptionPane.YES_OPTION ) { |
|
751 |
removeFromGroupByColums = true; |
|
752 |
} |
|
753 |
} |
|
754 |
if( this.query.getOrder().contains(attr.getName()) ) { |
|
755 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
756 |
int n = dialogs.confirmDialog( |
|
757 |
"El campo '"+attr.getName()+"' se esta usando para establecer el orden. ? Dese borrarlo igualmente ?", |
|
758 |
"Eliminar campo", |
|
759 |
JOptionPane.YES_NO_OPTION, |
|
760 |
JOptionPane.QUESTION_MESSAGE, |
|
761 |
"_FeatureQueryCalculatedColumns_remove_used_column" |
|
762 |
); |
|
763 |
if( n != JOptionPane.YES_OPTION ) { |
|
764 |
return; |
|
765 |
} |
|
766 |
|
|
767 |
n = dialogs.confirmDialog( |
|
768 |
"? Desea eliminar el uso del campo '"+attr.getName()+"' en la ordenacion ?", |
|
769 |
"Eliminar campo", |
|
770 |
JOptionPane.YES_NO_OPTION, |
|
771 |
JOptionPane.QUESTION_MESSAGE, |
|
772 |
"_FeatureQueryCalculatedColumns_remove_order_when_remove_column" |
|
773 |
); |
|
774 |
if( n == JOptionPane.YES_OPTION ) { |
|
775 |
removeFromOrder = true; |
|
776 |
} |
|
777 |
} |
|
778 |
if( removeFromAggregateFunctions ) { |
|
779 |
this.query.removeAggregateFunction(attr.getName()); |
|
780 |
} |
|
781 |
if( removeFromOrder ) { |
|
782 |
int index = this.query.getOrder().getIndex(attr.getName()); |
|
783 |
this.query.getOrder().remove(index); |
|
784 |
} |
|
785 |
if( removeFromGroupByColums ) { |
|
786 |
this.query.removeGroupByColumn(attr.getName()); |
|
787 |
} |
|
788 |
|
|
696 | 789 |
ListSelectionModel lsm = lstAttributes.getSelectionModel(); |
697 | 790 |
DefaultListModel model = (DefaultListModel) this.lstAttributes.getModel(); |
698 | 791 |
int actualIndex = lsm.getMinSelectionIndex(); |
699 |
Object selectedValue = this.lstAttributes.getSelectedValue(); |
|
700 | 792 |
this.lstAttributesModel.removeElement(selectedValue); |
701 | 793 |
this.columnController.clean(); |
702 | 794 |
|
Also available in: Unified diff