Revision 47466 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/gui/projectpanel/ProjectDocumentsPanelPage.java
ProjectDocumentsPanelPage.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.BorderLayout; |
4 | 4 |
import java.awt.Component; |
5 |
import org.gvsig.app.project.documents.gui.*; |
|
6 | 5 |
import java.awt.Dimension; |
7 | 6 |
import java.awt.FlowLayout; |
8 | 7 |
import java.awt.event.ActionEvent; |
... | ... | |
31 | 30 |
import javax.swing.SwingUtilities; |
32 | 31 |
import javax.swing.event.ListSelectionEvent; |
33 | 32 |
import javax.swing.event.ListSelectionListener; |
33 |
import org.apache.commons.lang3.ArrayUtils; |
|
34 | 34 |
import org.apache.commons.lang3.StringUtils; |
35 | 35 |
import org.gvsig.andami.IconThemeHelper; |
36 | 36 |
import org.gvsig.andami.PluginServices; |
... | ... | |
42 | 42 |
import org.gvsig.app.project.ProjectManager; |
43 | 43 |
import org.gvsig.app.project.documents.Document; |
44 | 44 |
import org.gvsig.app.project.documents.DocumentManager; |
45 |
import org.gvsig.app.project.documents.gui.*; |
|
45 | 46 |
import org.gvsig.tools.ToolsLocator; |
46 | 47 |
import org.gvsig.tools.dispose.DisposeUtils; |
47 | 48 |
import org.gvsig.tools.i18n.I18nManager; |
... | ... | |
175 | 176 |
} |
176 | 177 |
}); |
177 | 178 |
|
179 |
|
|
180 |
this.lstDocuments.addMouseListener(new java.awt.event.MouseAdapter() { |
|
181 |
|
|
182 |
public Document[] getSelecteds() { |
|
183 |
if (lstDocuments.getSelectedIndex() < 0) { |
|
184 |
return null; |
|
185 |
} |
|
186 |
Object[] seleteds = lstDocuments.getSelectedValues(); |
|
187 |
Document[] returnValue = new Document[seleteds.length]; |
|
188 |
System.arraycopy(seleteds, 0, returnValue, 0, |
|
189 |
seleteds.length); |
|
190 |
return returnValue; |
|
191 |
} |
|
192 |
|
|
193 |
public Document getItem(java.awt.event.MouseEvent e) { |
|
194 |
if (lstDocuments.getSelectedIndex() < 0) { |
|
195 |
return null; |
|
196 |
} |
|
197 |
|
|
198 |
return (Document) lstDocuments.getSelectedValue(); |
|
199 |
} |
|
200 |
|
|
201 |
@Override |
|
202 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
|
203 |
if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) { |
|
204 |
Document[] selecteds = this.getSelecteds(); |
|
205 |
Document item = this.getItem(e); |
|
206 |
if (item == null || ArrayUtils.isEmpty(selecteds)) { |
|
207 |
return; |
|
208 |
} |
|
209 |
DocumentContextMenu menu |
|
210 |
= new DocumentContextMenu( |
|
211 |
item.getTypeName(), |
|
212 |
item, |
|
213 |
selecteds); |
|
214 |
if (!menu.hasActions()) { |
|
215 |
return; |
|
216 |
} |
|
217 |
lstDocuments.add(menu); |
|
218 |
menu.show(e.getComponent(), e.getX(), e.getY()); |
|
219 |
return; |
|
220 |
} |
|
221 |
|
|
222 |
if (e.getClickCount() == 2) { |
|
223 |
doDocumentOpen(); |
|
224 |
} |
|
225 |
|
|
226 |
} |
|
227 |
}); |
|
228 |
|
|
178 | 229 |
this.lstDocuments.setCellRenderer(new DefaultListCellRenderer(){ |
179 | 230 |
@Override |
180 | 231 |
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
Also available in: Unified diff