use of org.omegat.filters2.IFilter in project omegat by omegat-org.
the class FiltersCustomizerController method initGui.
private void initGui() {
panel = new FiltersCustomizerPanel();
panel.filtersTable.setDefaultRenderer(String.class, new FilterFormatCellRenderer());
panel.filtersTable.getSelectionModel().addListSelectionListener(e -> {
if (e.getValueIsAdjusting()) {
return;
}
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if (lsm.isSelectionEmpty()) {
panel.editButton.setEnabled(false);
panel.optionsButton.setEnabled(false);
} else {
panel.editButton.setEnabled(true);
Filter currFilter = getFilterAtRow(panel.filtersTable.getSelectedRow());
IFilter f = FilterMaster.getFilterInstance(currFilter.getClassName());
panel.optionsButton.setEnabled(f != null && f.hasOptions());
}
});
panel.filtersTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent me) {
if (me.getClickCount() == 2 && me.getButton() == MouseEvent.BUTTON1) {
doEdit(panel.filtersTable.rowAtPoint(me.getPoint()));
}
}
});
TableColumnSizer.autoSize(panel.filtersTable, 0, true);
if (!isProjectSpecific) {
panel.projectSpecificCB.setVisible(false);
}
panel.projectSpecificCB.addActionListener(e -> updateEnabledness());
panel.cbRemoveTags.addActionListener(e -> editableFilters.setRemoveTags(panel.cbRemoveTags.isSelected()));
panel.cbRemoveSpacesNonseg.addActionListener(e -> editableFilters.setRemoveSpacesNonseg(panel.cbRemoveSpacesNonseg.isSelected()));
panel.cbPreserveSpaces.addActionListener(e -> editableFilters.setPreserveSpaces(panel.cbPreserveSpaces.isSelected()));
panel.cbIgnoreFileContext.addActionListener(e -> editableFilters.setIgnoreFileContext(panel.cbIgnoreFileContext.isSelected()));
panel.optionsButton.addActionListener(e -> {
Filter currFilter = getFilterAtRow(panel.filtersTable.getSelectedRow());
IFilter f = FilterMaster.getFilterInstance(currFilter.getClassName());
if (f != null) {
// new options handling
Map<String, String> newConfig = f.changeOptions(SwingUtilities.windowForComponent(panel), FilterMaster.forFilter(currFilter.getOption()));
if (newConfig != null) {
FilterMaster.setOptions(currFilter, newConfig);
}
}
});
panel.editButton.addActionListener(e -> doEdit(panel.filtersTable.getSelectedRow()));
if (Core.getProject().isProjectLoaded()) {
inUseFilters = Core.getProject().getProjectFiles().stream().map(info -> info.filterFileFormatName).collect(Collectors.toSet());
}
}
Aggregations