Search in sources :

Example 1 with Language

use of com.ramussoft.gui.spell.Language in project ramus by Vitaliy-Yakovchuk.

the class DFDSNamePanel method createChecker.

private void createChecker() {
    Properties ps = engine.getProperties(USER_GUI_SPELL_PROPERTIES);
    if (isSpellCheck(ps)) {
        Language language = getCurrentLanguage(ps);
        if (language != null) {
            checker = language.createTextComponentSpellChecker();
            checker.startRealtimeMarkErrors(textArea);
        }
    }
}
Also used : Language(com.ramussoft.gui.spell.Language) Properties(java.util.Properties)

Example 2 with Language

use of com.ramussoft.gui.spell.Language in project ramus by Vitaliy-Yakovchuk.

the class TextAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private TextPanelWithLinksDetector area = new TextPanelWithLinksDetector(TextAttributePlugin.this);

        protected JTextComponentSpellChecker checker;

        private Object value;

        private JPopupMenu createSelectLanguageMenu() {
            JMenu lMenu = new JMenu(GlobalResourcesManager.getString("Editor.Language"));
            Language[] languages = SpellFactory.getLanguages();
            final Properties ps = engine.getProperties(USER_GUI_SPELL_PROPERTIES);
            Language dLanguage = getCurrentLanguage(ps);
            ButtonGroup group = new ButtonGroup();
            for (Language l : languages) {
                final String ln = l.getName();
                JRadioButtonMenuItem item = new JRadioButtonMenuItem(new AbstractAction(l.getLocalizedName()) {

                    /**
                     */
                    private static final long serialVersionUID = -6106361308637383251L;

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        ps.setProperty(LANGUAGE, ln);
                        saveProperties(engine, ps);
                    }
                });
                lMenu.add(item);
                if ((dLanguage != null) && (dLanguage.equals(l)))
                    item.setSelected(true);
                group.add(item);
            }
            JPopupMenu menu = new JPopupMenu();
            JCheckBoxMenuItem item = new JCheckBoxMenuItem(GlobalResourcesManager.getString("Editor.SpellCheck"));
            item.setSelected(isSpellCheck(ps));
            item.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    Options.setBoolean(SPELL_CHECK, !isSpellCheck(ps), ps);
                    saveProperties(engine, ps);
                }
            });
            menu.add(item);
            menu.add(lMenu);
            return menu;
        }

        private void saveProperties(final Engine engine, final Properties ps) {
            engine.setProperties(USER_GUI_SPELL_PROPERTIES, ps);
            if (checker != null) {
                checker.stopRealtimeMarkErrors();
                checker = null;
            }
            createChecker();
        }

        private boolean isSpellCheck(final Properties ps) {
            return Options.getBoolean(SPELL_CHECK, true, ps);
        }

        private void createChecker() {
            Properties ps = engine.getProperties(USER_GUI_SPELL_PROPERTIES);
            if (isSpellCheck(ps)) {
                Language language = getCurrentLanguage(ps);
                if (language != null) {
                    checker = language.createTextComponentSpellChecker();
                    checker.startRealtimeMarkErrors(area);
                }
            }
        }

        private Language getCurrentLanguage(Properties ps) {
            String langName = Options.getString(LANGUAGE, "", ps);
            Language language;
            if ((langName == null) || (langName.equals("")))
                language = SpellFactory.getDefaultLanguage();
            else
                language = SpellFactory.findLanguage(langName);
            return language;
        }

        @Override
        public JComponent getComponent() {
            JScrollPane pane = new JScrollPane();
            pane.setViewportView(area);
            boolean canEdit = rules.canUpdateElement(element.getId(), attribute.getId());
            area.setEditable(canEdit);
            area.setComponentPopupMenu(createSelectLanguageMenu());
            createChecker();
            return pane;
        }

        @Override
        public Object getValue() {
            String res = area.getText();
            return ((res.equals("")) && (value == null)) ? null : res;
        }

        @Override
        public Object setValue(Object value) {
            this.value = value;
            area.setText((String) value);
            return value;
        }

        @Override
        public void close() {
            if (checker != null) {
                checker.stopRealtimeMarkErrors();
                checker = null;
            }
        }

        @Override
        public JComponent getLastComponent() {
            return area;
        }
    };
}
Also used : ActionEvent(java.awt.event.ActionEvent) JTextComponentSpellChecker(org.dts.spell.swing.JTextComponentSpellChecker) Properties(java.util.Properties) AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) Language(com.ramussoft.gui.spell.Language) ActionListener(java.awt.event.ActionListener)

Example 3 with Language

use of com.ramussoft.gui.spell.Language in project ramus by Vitaliy-Yakovchuk.

the class DFDSNamePanel method getCurrentLanguage.

private Language getCurrentLanguage(Properties ps) {
    String langName = Options.getString(LANGUAGE, "", ps);
    Language language;
    if ((langName == null) || (langName.equals("")))
        language = SpellFactory.getDefaultLanguage();
    else
        language = SpellFactory.findLanguage(langName);
    return language;
}
Also used : Language(com.ramussoft.gui.spell.Language)

Example 4 with Language

use of com.ramussoft.gui.spell.Language in project ramus by Vitaliy-Yakovchuk.

the class DFDSNamePanel method createSelectLanguageMenu.

private JPopupMenu createSelectLanguageMenu() {
    JMenu lMenu = new JMenu(GlobalResourcesManager.getString("Editor.Language"));
    Language[] languages = SpellFactory.getLanguages();
    final Properties ps = engine.getProperties(USER_GUI_SPELL_PROPERTIES);
    Language dLanguage = getCurrentLanguage(ps);
    ButtonGroup group = new ButtonGroup();
    for (Language l : languages) {
        final String ln = l.getName();
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(new AbstractAction(l.getLocalizedName()) {

            /**
             */
            private static final long serialVersionUID = -6106361308637383251L;

            @Override
            public void actionPerformed(ActionEvent e) {
                ps.setProperty(LANGUAGE, ln);
                saveProperties(engine, ps);
            }
        });
        lMenu.add(item);
        if ((dLanguage != null) && (dLanguage.equals(l)))
            item.setSelected(true);
        group.add(item);
    }
    JPopupMenu menu = new JPopupMenu();
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(GlobalResourcesManager.getString("Editor.SpellCheck"));
    item.setSelected(isSpellCheck(ps));
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Options.setBoolean(SPELL_CHECK, !isSpellCheck(ps), ps);
            saveProperties(engine, ps);
        }
    });
    menu.add(item);
    menu.add(lMenu);
    return menu;
}
Also used : ActionEvent(java.awt.event.ActionEvent) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Properties(java.util.Properties) JPopupMenu(javax.swing.JPopupMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) Language(com.ramussoft.gui.spell.Language) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu)

Example 5 with Language

use of com.ramussoft.gui.spell.Language in project ramus by Vitaliy-Yakovchuk.

the class HTMLEditPanel method createSelectLanguageMenu.

private JPopupMenu createSelectLanguageMenu() {
    JMenu lMenu = new JMenu(GlobalResourcesManager.getString("Editor.Language"));
    Language[] languages = SpellFactory.getLanguages();
    final Properties ps = engine.getProperties(USER_GUI_SPELL_PROPERTIES);
    Language dLanguage = getCurrentLanguage(ps);
    ButtonGroup group = new ButtonGroup();
    for (Language l : languages) {
        final String ln = l.getName();
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(new AbstractAction(l.getLocalizedName()) {

            /**
             */
            private static final long serialVersionUID = -6106361308637383251L;

            @Override
            public void actionPerformed(ActionEvent e) {
                ps.setProperty(LANGUAGE, ln);
                saveProperties(engine, ps);
            }
        });
        lMenu.add(item);
        if ((dLanguage != null) && (dLanguage.equals(l)))
            item.setSelected(true);
        group.add(item);
    }
    JPopupMenu menu = new JPopupMenu();
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(GlobalResourcesManager.getString("Editor.SpellCheck"));
    item.setSelected(isSpellCheck(ps));
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Options.setBoolean(SPELL_CHECK, !isSpellCheck(ps), ps);
            saveProperties(engine, ps);
        }
    });
    menu.add(item);
    menu.add(lMenu);
    return menu;
}
Also used : ActionEvent(java.awt.event.ActionEvent) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Properties(java.util.Properties) JPopupMenu(javax.swing.JPopupMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) Language(com.ramussoft.gui.spell.Language) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu)

Aggregations

Language (com.ramussoft.gui.spell.Language)8 Properties (java.util.Properties)6 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 ButtonGroup (javax.swing.ButtonGroup)3 JPopupMenu (javax.swing.JPopupMenu)3 AbstractAction (javax.swing.AbstractAction)2 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)2 JMenu (javax.swing.JMenu)2 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)2 Attribute (com.ramussoft.common.Attribute)1 Row (com.ramussoft.database.common.Row)1 AbstractAttributeEditor (com.ramussoft.gui.common.AbstractAttributeEditor)1 AbstractPreferences (com.ramussoft.gui.common.prefrence.AbstractPreferences)1 Preferences (com.ramussoft.gui.common.prefrence.Preferences)1 SelectableTableView (com.ramussoft.gui.qualifier.table.SelectableTableView)1 TableLayout (info.clearthought.layout.TableLayout)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 List (java.util.List)1