1 | |
package org.jtheque.core.managers.view.impl.frame; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.module.IModuleManager; |
21 | |
import org.jtheque.core.managers.update.repository.ModuleDescription; |
22 | |
import org.jtheque.core.managers.view.able.components.IModel; |
23 | |
import org.jtheque.core.managers.view.able.update.IRepositoryView; |
24 | |
import org.jtheque.core.managers.view.impl.actions.module.repository.ExpandRepositoryModuleAction; |
25 | |
import org.jtheque.core.managers.view.impl.actions.module.repository.InstallRepositoryModuleAction; |
26 | |
import org.jtheque.core.managers.view.impl.components.model.ModuleRepositoryListModel; |
27 | |
import org.jtheque.core.managers.view.impl.components.panel.ModulePanel; |
28 | |
import org.jtheque.core.managers.view.impl.components.renderers.ModuleRepositoryListRenderer; |
29 | |
import org.jtheque.core.managers.view.impl.frame.abstraction.SwingBuildedDialogView; |
30 | |
import org.jtheque.core.utils.ui.PanelBuilder; |
31 | |
import org.jtheque.utils.ui.GridBagUtils; |
32 | |
|
33 | |
import javax.swing.JList; |
34 | |
import javax.swing.ListSelectionModel; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
public final class RepositoryView extends SwingBuildedDialogView<IModel> implements IRepositoryView { |
42 | |
private JList list; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
public RepositoryView(){ |
48 | 0 | super(); |
49 | |
|
50 | 0 | build(); |
51 | 0 | } |
52 | |
|
53 | |
@Override |
54 | |
protected void initView(){ |
55 | 0 | setTitleKey("repository.view.title", Managers.getManager(IModuleManager.class).getRepository().getApplication()); |
56 | 0 | setResizable(false); |
57 | 0 | } |
58 | |
|
59 | |
@Override |
60 | |
protected void buildView(PanelBuilder builder){ |
61 | 0 | builder.addLabel(Managers.getManager(IModuleManager.class).getRepository().getTitle().toString(), |
62 | |
builder.gbcSet(0, 0, GridBagUtils.HORIZONTAL)); |
63 | |
|
64 | 0 | list = new JList(); |
65 | 0 | list.setModel(new ModuleRepositoryListModel()); |
66 | 0 | list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
67 | 0 | list.setCellRenderer(new ModuleRepositoryListRenderer()); |
68 | 0 | list.setVisibleRowCount(5); |
69 | |
|
70 | 0 | builder.addScrolled(list, builder.gbcSet(0, 1, GridBagUtils.BOTH)); |
71 | |
|
72 | 0 | builder.addButtonBar(builder.gbcSet(0, 2, GridBagUtils.HORIZONTAL), |
73 | |
new ExpandRepositoryModuleAction(), new InstallRepositoryModuleAction()); |
74 | 0 | } |
75 | |
|
76 | |
@Override |
77 | |
public ModuleDescription getSelectedModule() { |
78 | 0 | return (ModuleDescription) list.getSelectedValue(); |
79 | |
} |
80 | |
|
81 | |
@Override |
82 | |
public void expandSelectedModule() { |
83 | 0 | ModulePanel renderer = (ModulePanel) |
84 | |
list.getCellRenderer().getListCellRendererComponent( |
85 | |
list, list.getSelectedValue(), |
86 | |
list.getSelectedIndex(), true, true); |
87 | |
|
88 | 0 | renderer.expand(); |
89 | 0 | } |
90 | |
} |