<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package net.localizethat.actions;

import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import static javax.swing.Action.LARGE_ICON_KEY;
import javax.swing.ImageIcon;
import net.localizethat.Main;
import net.localizethat.gui.dialogs.ChooseTreePanel;
import net.localizethat.gui.dialogs.DialogDataObjects.ChooseTreeDDO;
import net.localizethat.gui.tabpanels.EditContentPanel;
import net.localizethat.util.gui.ModalDialog;

/**
 * Opens a tab with the general edit view, that shows a tree view of the paths,
 * an info panel, a table and a string edit panel
 * @author rpalomares
 */
public class EditContentAction extends AbstractAction {
    private static final String TITLE = "Edit Content";
    private static final String DESCRIPTION = "Opens the Edit Content Panel";
    private static final String ICON = "show-in-chrome.png";
    private static final int MNEMONIC = java.awt.event.KeyEvent.VK_H;
    private EditContentPanel editContentPanel;
    private ChooseTreePanel chooseTreePanel;
    private ChooseTreeDDO chooseTreeDDO;

    /**
     * Action representing the launching of LocaleManager panel as a tab in main window
     */
    public EditContentAction() {
        super(TITLE);
        putValue(SHORT_DESCRIPTION, DESCRIPTION);
        putValue(MNEMONIC_KEY, MNEMONIC);
        putValue(ACCELERATOR_KEY, javax.swing.KeyStroke.getKeyStroke(MNEMONIC, java.awt.event.InputEvent.CTRL_MASK));
        ImageIcon icon = new ImageIcon(LocaleManagerAction.class.getResource(
                    "/net/localizethat/resources/" + ICON));
        putValue(LARGE_ICON_KEY, icon);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        Main.mainWindow.getStatusBar().setInfoText("Creating window, please wait...");
        Thread tarea = new Thread(new Runnable() {
            @Override
            public void run(){
                if (editContentPanel == null) {
                    editContentPanel = new EditContentPanel();
                }
                Main.mainWindow.addTab(editContentPanel, TITLE);
                Main.mainWindow.getStatusBar().clearText();
            }
        });

        chooseTreePanel = new ChooseTreePanel();
        chooseTreeDDO = new ChooseTreeDDO();
        ModalDialog<ChooseTreePanel, ChooseTreeDDO> ctpDialog = new ModalDialog<>(Main.mainWindow,
                chooseTreePanel, true);
        ctpDialog.initDialog(chooseTreeDDO);
        tarea.start();
        ctpDialog.showDialog();
        chooseTreePanel = null;

        if (ctpDialog.getResult()) {
            // Not really needed, since ctpDialog uses the referenced object<commit_msg>We don't want an additional OK/Cancel button panel<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package net.localizethat.actions;

import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import static javax.swing.Action.LARGE_ICON_KEY;
import javax.swing.ImageIcon;
import net.localizethat.Main;
import net.localizethat.gui.dialogs.ChooseTreePanel;
import net.localizethat.gui.dialogs.DialogDataObjects.ChooseTreeDDO;
import net.localizethat.gui.tabpanels.EditContentPanel;
import net.localizethat.util.gui.ModalDialog;

/**
 * Opens a tab with the general edit view, that shows a tree view of the paths,
 * an info panel, a table and a string edit panel
 * @author rpalomares
 */
public class EditContentAction extends AbstractAction {
    private static final String TITLE = "Edit Content";
    private static final String DESCRIPTION = "Opens the Edit Content Panel";
    private static final String ICON = "show-in-chrome.png";
    private static final int MNEMONIC = java.awt.event.KeyEvent.VK_H;
    private EditContentPanel editContentPanel;
    private ChooseTreePanel chooseTreePanel;
    private ChooseTreeDDO chooseTreeDDO;

    /**
     * Action representing the launching of LocaleManager panel as a tab in main window
     */
    public EditContentAction() {
        super(TITLE);
        putValue(SHORT_DESCRIPTION, DESCRIPTION);
        putValue(MNEMONIC_KEY, MNEMONIC);
        putValue(ACCELERATOR_KEY, javax.swing.KeyStroke.getKeyStroke(MNEMONIC, java.awt.event.InputEvent.CTRL_MASK));
        ImageIcon icon = new ImageIcon(LocaleManagerAction.class.getResource(
                    "/net/localizethat/resources/" + ICON));
        putValue(LARGE_ICON_KEY, icon);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        Main.mainWindow.getStatusBar().setInfoText("Creating window, please wait...");
        Thread tarea = new Thread(new Runnable() {
            @Override
            public void run(){
                if (editContentPanel == null) {
                    editContentPanel = new EditContentPanel();
                }
                Main.mainWindow.addTab(editContentPanel, TITLE);
                Main.mainWindow.getStatusBar().clearText();
            }
        });

        chooseTreePanel = new ChooseTreePanel();
        chooseTreeDDO = new ChooseTreeDDO();
        ModalDialog<ChooseTreePanel, ChooseTreeDDO> ctpDialog = new ModalDialog<>(Main.mainWindow,
                chooseTreePanel, false);
        ctpDialog.initDialog(chooseTreeDDO);
        tarea.start();
        ctpDialog.showDialog();
        chooseTreePanel = null;

        if (ctpDialog.getResult()) {
            // Not really needed, since ctpDialog uses the referenced object
{'fraction_non_alphanumeric': 0.08933423913043478, 'fraction_numerical': 0.001358695652173913, 'mean_word_length': 3.052993805918789, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1686749', 'n_tokens_mistral': 1704, 'n_tokens_neox': 1640, 'n_words': 442}