- Timestamp:
- Sep 19, 2010, 11:40:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/MainFrame.java
r6958 r6972 6 6 import java.awt.event.ActionEvent; 7 7 import java.awt.event.ActionListener; 8 import java.awt.event.KeyEvent; 9 import java.awt.event.KeyListener; 8 10 import java.util.HashMap; 9 11 … … 22 24 import fr.mael.jiwigo.transverse.util.Messages; 23 25 import fr.mael.jiwigo.transverse.util.Outil; 26 import fr.mael.jiwigo.ui.field.HintTextField; 24 27 import fr.mael.jiwigo.ui.mainframe.tab.JTabbedPaneWithCloseIcons; 25 28 … … 53 56 * Frame principale 54 57 */ 55 public class MainFrame extends JFrame implements ActionListener {58 public class MainFrame extends JFrame implements ActionListener, KeyListener { 56 59 /** 57 60 * Logger … … 106 109 107 110 private HashMap<Integer, Integer> mapsIdPos = new HashMap<Integer, Integer>(); 111 112 private HintTextField fieldSearch; 108 113 109 114 /** … … 129 134 categoriesTree = new CategoriesTree(); 130 135 splitPane.setLeftComponent(categoriesTree); 131 // imagesPanel = new ThumbnailCategoryPanel(null);132 // reduceSizeOfComponent(imagesPanel);133 // scrollPaneImagesPanel = new JScrollPane(imagesPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,134 // JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);135 // scrollPaneImagesPanel.setPreferredSize(new Dimension(900, 600));136 136 137 137 tabbedPane = new JTabbedPaneWithCloseIcons(); 138 // tabbedPane.add(scrollPaneImagesPanel);139 138 splitPane.setRightComponent(tabbedPane); 140 139 141 140 this.add(splitPane, BorderLayout.CENTER); 141 JPanel panelBas = new JPanel(new BorderLayout()); 142 142 JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); 143 143 progressBar = new JProgressBar(0, 100); 144 144 panel.add(progressBar); 145 145 panel.add(labelMessage); 146 panelBas.add(panel, BorderLayout.WEST); 147 148 fieldSearch = new HintTextField(Messages.getMessage("mainFrame_recherche")); 149 fieldSearch.setPreferredSize(new Dimension(150, 25)); 150 fieldSearch.addKeyListener(this); 151 panelBas.add(fieldSearch, BorderLayout.EAST); 146 152 147 153 jMenuEdition = new JMenu(Messages.getMessage("mainFrame_editionMenu")); … … 152 158 153 159 this.setJMenuBar(jMenuBar); 154 this.add(panel, BorderLayout.SOUTH); 155 // this.pack(); 160 this.add(panelBas, BorderLayout.SOUTH); 156 161 this.setSize(900, 600); 157 162 this.setLocationRelativeTo(null); … … 160 165 } 161 166 162 public void addTabb( ThumbnailCategoryPanel panel) {163 JScrollPane scrollPaneImagesPanel = new JScrollPane( panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,167 public void addTabb(IThumbnailPanel panel) { 168 JScrollPane scrollPaneImagesPanel = new JScrollPane((JPanel) panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 164 169 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 165 170 scrollPaneImagesPanel.setPreferredSize(new Dimension(900, 600)); 166 171 boolean found = false; 172 boolean isSearch = false; 173 if (panel instanceof ThumbnailSearchPanel) { 174 isSearch = true; 175 } 167 176 for (int i = 0; i < tabbedPane.getTabCount(); i++) { 168 177 JScrollPane scroll = (JScrollPane) tabbedPane.getComponentAt(i); 169 ThumbnailCategoryPanel thumbPan = (ThumbnailCategoryPanel) scroll.getViewport().getComponents()[0];178 IThumbnailPanel thumbPan = (IThumbnailPanel) scroll.getViewport().getComponents()[0]; 170 179 if (thumbPan.getCategory().getIdentifiant().equals(panel.getCategory().getIdentifiant())) { 171 tabbedPane.setSelectedIndex(i); 172 found = true; 173 break; 180 //only if it's not for a re 181 if (!(panel instanceof ThumbnailSearchPanel)) { 182 tabbedPane.setSelectedIndex(i); 183 found = true; 184 break; 185 } 174 186 } 175 187 } 176 if (!found) { 188 //if it's not for a research, the title of the tab 189 //is the name of the category 190 if (!found && !isSearch) { 177 191 tabbedPane.addTab(panel.getCategory().getNom(), scrollPaneImagesPanel, new ImageIcon(Outil 178 192 .getURL("fr/mael/jiwigo/img/closetab.png"))); 179 } 180 181 // if (mapsIdPos.get(panel.getCategory().getIdentifiant()) == null) { 182 // tabbedPane.addTab(panel.getCategory().getNom(), scrollPaneImagesPanel); 183 // mapsIdPos.put(panel.getCategory().getIdentifiant(), tabbedPane.getTabCount() - 1); 184 // } else { 185 // tabbedPane.setSelectedIndex(mapsIdPos.get(panel.getCategory().getIdentifiant())); 186 // } 193 //if it's for a research, the title of the tab 194 //if the query string 195 } else if (!found && isSearch) { 196 String queryString = ((ThumbnailSearchPanel) panel).getQueryString(); 197 tabbedPane.addTab(Messages.getMessage("mainFrame_search") + queryString, scrollPaneImagesPanel, 198 new ImageIcon(Outil.getURL("fr/mael/jiwigo/img/closetab.png"))); 199 } 187 200 188 201 } … … 237 250 } 238 251 252 @Override 253 public void keyPressed(KeyEvent paramKeyEvent) { 254 if (paramKeyEvent.getKeyCode() == KeyEvent.VK_ENTER) { 255 String queryString = fieldSearch.getText(); 256 ThumbnailSearchPanel searchPanel = new ThumbnailSearchPanel(queryString); 257 addTabb(searchPanel); 258 } 259 } 260 261 @Override 262 public void keyReleased(KeyEvent paramKeyEvent) { 263 } 264 265 @Override 266 public void keyTyped(KeyEvent paramKeyEvent) { 267 } 268 239 269 }
Note: See TracChangeset
for help on using the changeset viewer.