Revision 46463

View differences:

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/searchpanel/DefaultSearchPanel.java
112 112
import static org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue.ID_GETVALUE;
113 113
import static org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue.ID_SETVALUE;
114 114
import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController;
115
import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController.BookmarkEvent;
115 116
import org.gvsig.tools.swing.api.bookmarkshistory.HistoryController;
116 117
import org.gvsig.tools.swing.api.task.TaskStatusController;
117 118
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
......
712 713

  
713 714
		this.historyController.setFilter(null);
714 715

  
715
		ActionListener bookmarksAndHistoryListener = (ActionEvent e) -> {
716
		this.historyController.addActionListener((ActionEvent e) -> {
716 717
			ActionEventWithCurrentValue<DefaultSearchParameters> b = (ActionEventWithCurrentValue<DefaultSearchParameters>) e;
717 718
			switch (b.getID()) {
718 719
				case ID_GETVALUE:
......
724 725
					if (b.getCurrentValue() == null) {
725 726
						return;
726 727
					}
727
					DefaultSearchParameters searchParams;
728
					try {
729
						searchParams = b.getCurrentValue().getCopy();
730
                                                searchParams.fix(this.getFeatureType());
731
                                                // TODO: habria que comprobar y preguntar al usuario de forma
732
                                                // similar a lo que se hace en DefaultFeatureQueryCalculatedColumnsPanel.doRemove
733
					} catch (Exception ex) {
734
						LOGGER.warn("Not been able to clone export parameters", ex);
728
                                        doSearchFromParameters(b.getCurrentValue());
729
					break;
730
			}
731
		});
732
		this.bookmarksController.addActionListener((ActionEvent e) -> {
733
			BookmarkEvent<DefaultSearchParameters> b = (BookmarkEvent<DefaultSearchParameters>) e;
734
			switch (b.getID()) {
735
				case ID_GETVALUE:
736
					DefaultSearchParameters actualParams = (DefaultSearchParameters) fetch(null);
737
					b.setCurrentValue(actualParams);
738
					break;
739

  
740
				case ID_SETVALUE:
741
					if (b.getCurrentValue() == null) {
735 742
						return;
736 743
					}
737
					clear();
738
					put(searchParams);
739
					Thread th = new Thread(() -> {
740
						doSearch(searchParams);
741
					});
742
					th.start();
744
                                        b.getBookmark().used();
745
                                        doSearchFromParameters(b.getCurrentValue());
743 746
					break;
744 747
			}
745
		};
746
		this.historyController.addActionListener(bookmarksAndHistoryListener);
747
		this.bookmarksController.addActionListener(bookmarksAndHistoryListener);
748
		});
748 749
		this.addComponentListener(new ComponentAdapter() {
749 750
			@Override
750 751
			public void componentHidden(ComponentEvent e) {
......
775 776
		this.tblResults.setComponentPopupMenu(new TablePopupMenu(this.tblResults));
776 777
		this.tblSearchPostProcessResults.setComponentPopupMenu(new TablePopupMenu(this.tblSearchPostProcessResults));
777 778

  
778
		//this.tblResults.add
779
		if (this.bookmarks.hasBookmark(this.store.getName())) {
780
			Bookmark<DefaultSearchParameters> initBookmark = this.bookmarks.get(this.store.getName());
781
			DefaultSearchParameters initSearchParams = initBookmark.getValue().getCopy();
782
			put(initSearchParams);
783
			Thread th = new Thread(() -> {
784
				doSearch(initSearchParams);
785
			});
786
			th.start();
787
			return;
788
		}
789

  
790 779
		this.tabResults.addChangeListener((ChangeEvent evt) -> {
791 780
			SwingUtilities.invokeLater(() -> {
792 781
				if (tabResults.getSelectedIndex() == 0) {
......
799 788
		if (this.filterOnlyMode) {
800 789
			this.btnSearchPostProcess.setVisible(false);
801 790
		}
802
		clear();
803
		search();
791

  
792
		//this.tblResults.add
793
		if (this.bookmarks.hasBookmark(this.store.getName())) {
794
			Bookmark<DefaultSearchParameters> initBookmark = this.bookmarks.get(this.store.getName());
795
                        initBookmark.used();
796
                        doSearchFromParameters(initBookmark.getValue());
797
		} else {
798
                    clear();
799
                    search();
800
                }
804 801
	}
802
        
803
    private void doSearchFromParameters(DefaultSearchParameters searchParams) {
804
        DefaultSearchParameters params;
805
        try {
806
            params = searchParams.getCopy();
807
            params.fix(this.getFeatureType());
808
            // TODO: habria que comprobar y preguntar al usuario de forma
809
            // similar a lo que se hace en DefaultFeatureQueryCalculatedColumnsPanel.doRemove
810
        } catch (Exception ex) {
811
            LOGGER.warn("Not been able to clone export parameters", ex);
812
            return;
813
        }
814
        clear();
815
        put(params);
816
        Thread th = new Thread(() -> {
817
            doSearch(params);
818
        });
819
        th.start();
805 820

  
821
    }
822

  
806 823
	private void doShowCellInDialog() {
807 824
		int row = this.tblResults.getSelectedRow();
808 825
		if (row < 0) {

Also available in: Unified diff