Revision 4561dd9c
Added by Alexander Oppermann over 9 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/listener/ChecklistDropdownSelectionListener.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.SortedSet; |
4 | 4 |
|
5 |
import org.apache.log4j.Logger; |
|
5 | 6 |
import org.eclipse.jface.viewers.TableViewer; |
6 | 7 |
import org.eclipse.jface.wizard.WizardDialog; |
7 | 8 |
import org.eclipse.swt.SWT; |
... | ... | |
32 | 33 |
public class ChecklistDropdownSelectionListener extends SelectionAdapter { |
33 | 34 |
|
34 | 35 |
private final Menu menu; |
35 |
private final ToolItem dropdown; |
|
36 | 36 |
private final ChecklistEditor editor; |
37 | 37 |
private final SortedSet<DefinedTermBase> termSet; |
38 |
|
|
38 |
private Logger logger = Logger.getLogger(ChecklistDropdownSelectionListener.class); |
|
39 |
|
|
39 | 40 |
public ChecklistDropdownSelectionListener(ToolItem dropdown, ChecklistEditor editor, |
40 | 41 |
SortedSet<DefinedTermBase> termSet) { |
41 |
this.dropdown = dropdown; |
|
42 | 42 |
this.editor = editor; |
43 | 43 |
this.termSet = termSet; |
44 | 44 |
menu = new Menu(dropdown.getParent().getShell()); |
... | ... | |
65 | 65 |
TableColumn column = null; |
66 | 66 |
DefinedTermBase<DefinedTermBase> selectedTerm = null; |
67 | 67 |
if (termSet != null) { |
68 |
int i = 0; |
|
69 |
for (DefinedTermBase<DefinedTermBase> term : termSet) { |
|
70 |
if (term != null) { |
|
71 |
if (selected.getText().equalsIgnoreCase(term.getTitleCache())) { |
|
72 |
selectedTerm = term; |
|
73 |
column = table.getColumn(4 + i); |
|
74 |
} |
|
75 |
i++; |
|
76 |
} |
|
77 |
} |
|
68 |
TableColumn[] columns = viewer.getTable().getColumns(); |
|
69 |
for(int i=0; i<columns.length; i++){ |
|
70 |
if(selected.getText().equalsIgnoreCase(columns[i].getText())){ |
|
71 |
column = columns[i]; |
|
72 |
logger.info("Column no " +i +" Column Header "+ column.getText() ); |
|
73 |
for (DefinedTermBase<DefinedTermBase> term : termSet) { |
|
74 |
if(column.getText().equalsIgnoreCase(term.getTitleCache())){ |
|
75 |
selectedTerm = term; |
|
76 |
break; |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
78 | 81 |
} |
79 | 82 |
if (column != null && column.getWidth() == 0) { |
80 | 83 |
// save column status if shown or not |
... | ... | |
88 | 91 |
} |
89 | 92 |
column.setWidth(0); |
90 | 93 |
} |
91 |
viewer.refresh(); |
|
92 | 94 |
} |
93 | 95 |
}); |
94 | 96 |
} |
... | ... | |
103 | 105 |
WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), |
104 | 106 |
availableDistributionWizard); |
105 | 107 |
|
106 |
dialog.open(); |
|
108 |
int open = dialog.open(); |
|
109 |
if(open == 0){ |
|
110 |
editor.reload(); |
|
111 |
} |
|
107 | 112 |
} |
108 | 113 |
}); |
109 | 114 |
new MenuItem(menu, SWT.SEPARATOR); |
... | ... | |
121 | 126 |
menu.setVisible(true); |
122 | 127 |
} |
123 | 128 |
} |
129 |
|
|
130 |
public Menu getMenu(){ |
|
131 |
return menu; |
|
132 |
} |
|
124 | 133 |
} |
Also available in: Unified diff
Added a reload function so that the checklist editor doesn't need to be relaunched after adding terms.