<commit_before>package rhogenwizard.actions;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.osgi.service.prefs.BackingStoreException;

import rhogenwizard.DialogUtils;
import rhogenwizard.project.ProjectFactory;
import rhogenwizard.project.RhodesProject;
import rhogenwizard.project.RhoelementsProject;
import rhogenwizard.rhohub.IRhoHubSetting;
import rhogenwizard.rhohub.IRhoHubSettingSetter;
import rhogenwizard.rhohub.RhoHub;
import rhogenwizard.rhohub.RhoHubBundleSetting;
import rhogenwizard.wizards.rhohub.BuildWizard;
import rhogenwizard.wizards.rhohub.LinkWizard;


//InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "", "Please input text.",
//    "Test-Text", null) {
//  @Override
//  protected int getInputTextStyle() {
//    return SWT.SINGLE | SWT.BORDER ;
//  }
//};
//dlg.open();

public class RhohubWizardAction implements IWorkbenchWindowActionDelegate
{
    private static int wizardHeigth = 500;
    private static int wizardWidth  = 800;
        
    private IWorkbenchWindow window;

    /**
     * The action has been activated. The argument of the method represents the
     * 'real' action sitting in the workbench UI.
     * 
     * @see IWorkbenchWindowActionDelegate#run
     */
    public void run(IAction action)
    {       
        IProject project = ProjectFactory.getInstance().getSelectedProject();

        if (project == null)
        {
            DialogUtils.error("Error", "Before run remote build select RhoMobile project's");
            return;
        }

        if (!RhodesProject.checkNature(project) && !RhoelementsProject.checkNature(project))
        {
            DialogUtils.error("Error", "Remote build can run only for RhoMobile project's");
            return;
        }
        
        if (!checkProjectProperties(project))
        {
            if (DialogUtils.confirm("Project setting", "For project " + project.getName() + 
                    " not found infomation on RhoHub. Link the project with project on RhoHub server?"))
            {
                LinkWizard linkWizard = new LinkWizard(project);
                
                if (createWizardDialog(linkWizard) == Window.CANCEL)
                    return;
            }
            else
            {
                return;
            }
        }

        BuildWizard  buildWizard =  new BuildWizard(project);
        createWizardDialog(buildWizard);
    }
    
    int createWizardDialog(IWizard wizard)
    {
        WizardDialog buildWizardDialog = new WizardDialog(window.getShell(), wizard) 
        {
            @Override
            protected void configureShell(Shell newShell) 
            {
                super.configureShell(newShell);
                newShell.setSize(wizardWidth, wizardHeigth);
            }       
        };
        
        buildWizardDialog.create();
        return buildWizardDialog.open(); 
    }

    private boolean checkProjectProperties(IProject project)
    {
        IRhoHubSetting setting = new RhoHubBundleSetting(project);
        
        if (!setting.isLinking())<commit_msg>final stage of action<commit_after>package rhogenwizard.actions;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.osgi.service.prefs.BackingStoreException;

import rhogenwizard.DialogUtils;
import rhogenwizard.project.ProjectFactory;
import rhogenwizard.project.RhodesProject;
import rhogenwizard.project.RhoelementsProject;
import rhogenwizard.rhohub.IRhoHubSetting;
import rhogenwizard.rhohub.IRhoHubSettingSetter;
import rhogenwizard.rhohub.RhoHub;
import rhogenwizard.rhohub.RhoHubBundleSetting;
import rhogenwizard.wizards.rhohub.LinkWizard;

public class RhohubWizardAction implements IWorkbenchWindowActionDelegate
{
    private static int wizardHeigth = 500;
    private static int wizardWidth  = 800;
        
    private IWorkbenchWindow window;

    /**
     * The action has been activated. The argument of the method represents the
     * 'real' action sitting in the workbench UI.
     * 
     * @see IWorkbenchWindowActionDelegate#run
     */
    public void run(IAction action)
    {       
        IProject project = ProjectFactory.getInstance().getSelectedProject();

        if (project == null)
        {
            DialogUtils.error("Error", "Before run remote build select RhoMobile project's");
            return;
        }

        if (!RhodesProject.checkNature(project) && !RhoelementsProject.checkNature(project))
        {
            DialogUtils.error("Error", "Remote build can run only for RhoMobile project's");
            return;
        }

        LinkWizard linkWizard = new LinkWizard(project);
        
        if (createWizardDialog(linkWizard) == Window.CANCEL)
            return;
/*
        if (!checkProjectProperties(project))
        {
            if (DialogUtils.confirm("Project setting", "For project " + project.getName() + 
                    " not found infomation on RhoHub. Link the project with project on RhoHub server?"))
            {
                LinkWizard linkWizard = new LinkWizard(project);
                
                if (createWizardDialog(linkWizard) == Window.CANCEL)
                    return;
            }
            else
            {
                return;
            }
        }

        BuildWizard  buildWizard =  new BuildWizard(project);
        createWizardDialog(buildWizard);
        */
    }
    
    int createWizardDialog(IWizard wizard)
    {
        WizardDialog buildWizardDialog = new WizardDialog(window.getShell(), wizard) 
        {
            @Override
            protected void configureShell(Shell newShell) 
            {
                super.configureShell(newShell);
                newShell.setSize(wizardWidth, wizardHeigth);
            }       
        };
        
        buildWizardDialog.create();
        return buildWizardDialog.open(); 
    }

    private boolean checkProjectProperties(IProject project)
    {
        IRhoHubSetting setting = new RhoHubBundleSetting(project);
        
        if (!setting.isLinking())
{'fraction_non_alphanumeric': 0.08660251665433012, 'fraction_numerical': 0.001776461880088823, 'mean_word_length': 2.5260960334029225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5216204', 'n_tokens_mistral': 1930, 'n_tokens_neox': 1842, 'n_words': 383}