try {
            return ParticleArgument.parseParticle(new StringReader(name));
        } catch (CommandSyntaxException e) {
            throw new RuntimeException("No such particle: " + name);
        }

package carpet.logging.logHelpers;

import carpet.logging.LoggerRegistry;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.arguments.ParticleArgument;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.particles.IParticleData;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.WorldServer;

public class PathfindingVisualizer {

    private static IParticleData failedPath;

    private static IParticleData successfulPath;

    private static IParticleData lvl1;

    private static IParticleData lvl2;

    private static IParticleData lvl3;

    static {
        failedPath = parseParticle("angry_villager");
        successfulPath = parseParticle("happy_villager");
        lvl1 = parseParticle("dust 1 1 0 1");
        lvl2 = parseParticle("dust 1 0.5 0 1");
        lvl3 = parseParticle("dust 1 0 0 1");
    }

    private static void drawParticleLine(EntityPlayerMP player, Vec3d from, Vec3d to, float ratio, boolean successful) {
        IParticleData accent = successful ? successfulPath : failedPath;
        IParticleData color = (ratio < 2) ? lvl1 : ((ratio < 4) ? lvl2 : lvl3);
        ((WorldServer) player.world).spawnParticle(player, accent, true, from.x, from.y, from.z, 5, 0.5, 0.5, 0.5, 0.0);
        double lineLengthSq = from.squareDistanceTo(to);
        if (lineLengthSq == 0)
            return;
        Vec3d incvec = to.subtract(from).normalize();
        int pcount = 0;
        for (Vec3d delta = new Vec3d(0.0, 0.0, 0.0); delta.lengthSquared() < lineLengthSq; delta = delta.add(incvec.scale(player.world.rand.nextFloat()))) {
            ((WorldServer) player.world).spawnParticle(player, color, true, delta.x + from.x, delta.y + from.y, delta.z + from.z, 1, 0.0, 0.0, 0.0, 0.0);
        }
    }

    private static IParticleData parseParticle(String name) {

    }

    public static void slowPath(Entity entity, Vec3d target, float miliseconds, boolean successful) {
        if (!LoggerRegistry.__pathfinding)
            return;
        LoggerRegistry.getLogger("pathfinding").log((option, player) -> {
            if (!(player instanceof EntityPlayerMP))
                return null;
            int minDuration = Integer.parseInt(option);
            if (miliseconds < minDuration)
                return null;
            if (player.getDistanceSq(entity) > 1000 && player.getDistanceSq(target) > 1000)
                return null;
            if (minDuration < 1)
                minDuration = 1;
            drawParticleLine((EntityPlayerMP) player, entity.getPositionVector(), target, miliseconds / minDuration, successful);
            return null;
        });
    }
}


package org.jcryptool.analysis.freqanalysis.ui;

import java.math.BigInteger;
import java.util.Observable;
import java.util.Observer;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.jcryptool.analysis.freqanalysis.calc.FreqAnalysisCalc;
import org.jcryptool.core.operations.algorithm.classic.textmodify.TransformData;
import org.jcryptool.crypto.ui.background.BackgroundJob;
import org.jcryptool.crypto.ui.textloader.ui.wizard.TextLoadController;
import org.jcryptool.crypto.ui.textsource.TextInputWithSource;

/**
 * @author SLeischnig
 */
public class SimpleAnalysisUI extends AbstractAnalysisUI {

    private Composite composite0;

    private Composite composite1;

    private Group group1;

    private Label label1;

    private Button button4;

    private Composite composite2;

    private Group group4;

    private Label label2;

    private Group group2;

    private Composite composite3;

    private TabFolder tabFolder1;

    private TabItem tabItem1;

    private TabItem tabItem2;

    private Composite composite4;

    private Label label3;

    private Label label4;

    private Label label5;

    private Text text1;

    private TextInputWithSource source;

    private FreqAnalysisCalc myAnalysis;

    TransformData myModifySettings;

    private TextLoadController textloader;

    public FreqAnalysisCalc return__freqanalysis;

    private static final int simpleFreqAnalysis_text_max_length = 999999;

    private TextInputWithSource lastSuccessfullLoadedText;

    public SimpleAnalysisUI(final Composite parent, final int style) {
        super(parent, style);
        initGUI();
        hideObject(group2, button3.getSelection());
        myModifySettings = new TransformData();
        myModifySettings.setUnmodified();
    }

{
        setLayout(new GridLayout());
        composite0 = new Composite(this, SWT.NONE);
        composite0.setLayout(new GridLayout(2, false));
        composite0.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
        textloader = new TextLoadController(composite0, this, SWT.NONE, true, true);
        textloader.addObserver(new Observer() {

            @Override
            public void update(Observable o, Object arg) {
                if (textloader.getText() != null) {
                    myGraph.getFrequencyGraph().setInstruction(Messages.FreqAnalysisGraph_graph1);
                    myGraph.redraw();
                    if (textloader.getText().getText().length() < simpleFreqAnalysis_text_max_length) {
                        text = textloader.getText().getText();
                        lastSuccessfullLoadedText = textloader.getText();
                        source = textloader.getText();
                    } else {
                        boolean result = MessageDialog.openQuestion(SimpleAnalysisUI.this.getShell(), Messages.SimpleAnalysisUI_warning, Messages.SimpleAnalysisUI_warning_text);
                        if (result) {
                            text = textloader.getText().getText();
                            source = textloader.getText();
                        } else {
                            textloader.setTextData(lastSuccessfullLoadedText, null, true);
                            source = lastSuccessfullLoadedText;
                            return;
                        }
                    }
                    recalcSourceInfo();
                    myGraph.getFrequencyGraph().setInstruction(Messages.FreqAnalysisGraph_shiftgraph0);
                    if (text.equals("") || text == null) {
                        MessageDialog.openInformation(getShell(), Messages.AbstractAnalysisUI_0, Messages.AbstractAnalysisUI_2);
                    } else {
                        recalcGraph();
                    }
                }
            }
        });
        // @Override
        // String line;
        // @Override
        // @Override
        composite1 = new Composite(this, SWT.NONE);
        composite1.setLayout(new GridLayout(2, false));
        composite1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group1 = new Group(composite1, SWT.NONE);
        group1.setLayout(new GridLayout());
        group1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group1.setText(Messages.SimpleAnalysisUI_graphlabel);
        myGraph = new CustomFreqCanvas(group1, SWT.NONE);
        myGraph.setLayout(new GridLayout());
        myGraph.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group4 = new Group(composite1, SWT.NONE);
        group4.setLayout(new GridLayout());
        group4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
        group4.setText(Messages.SimpleAnalysisUI_properties);
        tabFolder1 = new TabFolder(group4, SWT.NONE);
        tabItem1 = new TabItem(tabFolder1, SWT.NONE);
        tabItem1.setText(Messages.FullAnalysisUI_firsttablabel);
        composite3 = new Composite(tabFolder1, SWT.NONE);
        composite3.setLayout(new GridLayout());
        composite3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        tabItem1.setControl(composite3);
        composite2 = new Composite(composite3, SWT.NONE);
        composite2.setLayout(new GridLayout());
        composite2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        button3 = new Button(composite2, SWT.RADIO);
        button3.setText(Messages.SimpleAnalysisUI_monoalphabetic);
        button3.setSelection(true);
        button3.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                polyOnOffSelected(evt);
            }
        });
        button4 = new Button(composite2, SWT.RADIO);
        button4.setText(Messages.SimpleAnalysisUI_polyalphabetic);
        button4.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                polyOnOffSelected(evt);
            }
        });
        Label lblPolyalphabetic = new Label(composite2, SWT.WRAP);
        lblPolyalphabetic.setText(Messages.FullAnalysisUI_6);
        GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
        layoutData.widthHint = 100;
        lblPolyalphabetic.setLayoutData(layoutData);
        group2 = new Group(composite2, SWT.NONE);
        group2.setLayout(new GridLayout(2, false));
        group2.setText(Messages.SimpleAnalysisUI_vigeneresettings);
        spinner1 = new Spinner(group2, SWT.NONE);
        spinner1.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent evt) {
                recalcGraph();
            }
        });
        spinner1.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                changedVigOptions();
            }
        });
        spinner1.setSelection(1);
        label1 = new Label(group2, SWT.NONE);
        label1.setText(Messages.SimpleAnalysisUI_keylength);
        spinner2 = new Spinner(group2, SWT.NONE);
        spinner2.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent evt) {
                recalcGraph();
            }
        });
        spinner2.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                changedVigOptions();
            }
        });
        spinner2.setSelection(0);
        label2 = new Label(group2, SWT.NONE);
        label2.setText(Messages.SimpleAnalysisUI_offset);
        // @Override
        tabItem2 = new TabItem(tabFolder1, SWT.NONE);
        tabItem2.setText(Messages.FullAnalysisUI_thirdtablabel);
        composite4 = new Composite(tabFolder1, SWT.NONE);
        composite4.setLayout(new GridLayout());
        tabItem2.setControl(composite4);
        label3 = new Label(composite4, SWT.WRAP);
        GridData layoutData1 = new GridData(SWT.FILL, SWT.FILL, true, false);
        label3.setLayoutData(layoutData1);
        label4 = new Label(composite4, SWT.WRAP);
        GridData layoutData2 = new GridData(SWT.FILL, SWT.FILL, true, false);
        label4.setLayoutData(layoutData2);
        label5 = new Label(composite4, SWT.NONE);
        label5.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        text1 = new Text(composite4, SWT.V_SCROLL | SWT.BORDER | SWT.MULTI | SWT.WRAP);
        text1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        recalcSourceInfo();
        tabFolder1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        tabFolder1.setSelection(0);
        layout();
    }

    /**
     * Method for aggregating information about source text file.
     */
    protected void recalcSourceInfo() {
        if (text == null) {
            label3.setText(Messages.FullAnalysisUI_source + " -");
            label4.setText(Messages.FullAnalysisUI_textlength + " -");
            text1.setText("");
            composite4.layout(new Control[] { label3, label4 });
        } else {
            label3.setText(Messages.FullAnalysisUI_source + " " + source.toString());
            String totalLength = Integer.toString(text.length());
            label4.setText(Messages.FullAnalysisUI_textlength + " " + totalLength);
            label5.setText(Messages.FullAnalysisUI_textexcerpt);
            text1.setText(text.substring(0, (text.length() > 1000) ? 1000 : text.length()) + ((text.length() > 1000) ? "..." : ""));
            text1.setEditable(false);
        }
    }

    /**
     * executes a TextModify Wizard.
     *
     * @param the Settings that have to be displayed at the beginning.
     * @return the selected settings.
     */
    public class FreqAnalysisJob extends BackgroundJob {

        private String text;

        private int myLength;

        private int myOffset;

        private String myOverlayAlphabet;

        public TransformData myModifySettings;

        @Override
        public String name() {
            return "Frequency Analysis";
        }

        @Override
        public IStatus computation(IProgressMonitor monitor) {
            SimpleAnalysisUI.this.return__freqanalysis = new FreqAnalysisCalc(this.text, this.myLength, this.myOffset, this.myModifySettings);
            return Status.OK_STATUS;
        }
    }

    /**
     * frequency analysis main procedure
     */
    @Override
    protected void analyze() {
        FreqAnalysisJob job = new FreqAnalysisJob();
        job.text = text;
        job.myLength = myLength;
        job.myOffset = myOffset;
        job.myModifySettings = myModifySettings;
        job.finalizeListeners.add(status -> {
            getDisplay().syncExec(() -> {
                job.liftNoClickDisplaySynced(getDisplay());
                if (status == Status.OK_STATUS) {
                    myAnalysis = return__freqanalysis;
                    myGraph.setAnalysis(myAnalysis);
                }
            });
        });
        job.imposeNoClickDisplayCurrentShellSynced(getDisplay());
        job.runInBackground();
    }

    /**
     * excludes a control from the Layout calculation
     *
     * @param that
     * @param hideit
     */
    private void hideObject(final Control that, final boolean hideit) {
        GridData GData = (GridData) that.getLayoutData();
        // the (GData != null) test is to work around a NullPointerException (bug #95)
        // happening after one leaves the Frequency Analysis open
        // while closing down JCrypTool, then restarts JCrypTool
        if (GData != null) {
            GData.exclude = true && hideit;
        }
        that.setVisible(true && !hideit);
        Control[] myArray = { that };
        layout(myArray);
    }

    private void polyOnOffSelected(final SelectionEvent evt) {
        hideObject(group2, button3.getSelection());
    }

    private void changedVigOptions() {
        if (spinner1.getSelection() < 1) {
            spinner1.setSelection(1);
        }
        if (spinner2.getSelection() < 0) {
            spinner2.setSelection(0);
        }
        spinner1.setMinimum(1);
        spinner1.setMaximum(999999);
        spinner2.setMinimum(0);
        spinner2.setMaximum(spinner1.getSelection() - 1);
        if (spinner2.getSelection() >= spinner1.getSelection()) {
            spinner2.setSelection(spinner1.getSelection() - 1);
        }
        spinner2.setMaximum(spinner1.getSelection());
    }

    public final void execute(final int keyLength, final int keyPos, final boolean resetShift, final boolean executeCalc) {
        if (keyLength > 0) {
            if (keyLength == 1) {
                button3.setSelection(true);
                button4.setSelection(false);
            } else {
                button3.setSelection(false);
                button4.setSelection(true);
            }
            polyOnOffSelected(null);
            spinner1.setSelection(keyLength);
            changedVigOptions();
            if (keyPos < 0) {
                recalcGraph();
            }
        }
        if (keyPos > -1) {
            spinner2.setSelection(keyPos);
            changedVigOptions();
            recalcGraph();
        }
        if (resetShift) {
            myGraph.getFrequencyGraph().resetDrag();
        }
        if (executeCalc) {
            if (checkEditor()) {
                text = getEditorText();
                recalcGraph();
            }
        }
    }

    public void resetClick() {
        // TODO Auto-generated method stub
    }
}


{
                recalcGraph();
            }

package org.jcryptool.analysis.freqanalysis.ui;

import java.math.BigInteger;
import java.util.Observable;
import java.util.Observer;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.jcryptool.analysis.freqanalysis.calc.FreqAnalysisCalc;
import org.jcryptool.core.operations.algorithm.classic.textmodify.TransformData;
import org.jcryptool.crypto.ui.background.BackgroundJob;
import org.jcryptool.crypto.ui.textloader.ui.wizard.TextLoadController;
import org.jcryptool.crypto.ui.textsource.TextInputWithSource;

/**
 * @author SLeischnig
 */
public class SimpleAnalysisUI extends AbstractAnalysisUI {

    private Composite composite0;

    private Composite composite1;

    private Group group1;

    private Label label1;

    private Button button4;

    private Composite composite2;

    private Group group4;

    private Label label2;

    private Group group2;

    private Composite composite3;

    private TabFolder tabFolder1;

    private TabItem tabItem1;

    private TabItem tabItem2;

    private Composite composite4;

    private Label label3;

    private Label label4;

    private Label label5;

    private Text text1;

    private TextInputWithSource source;

    private FreqAnalysisCalc myAnalysis;

    TransformData myModifySettings;

    private TextLoadController textloader;

    public FreqAnalysisCalc return__freqanalysis;

    private static final int simpleFreqAnalysis_text_max_length = 999999;

    private TextInputWithSource lastSuccessfullLoadedText;

    public SimpleAnalysisUI(final Composite parent, final int style) {
        super(parent, style);
        initGUI();
        hideObject(group2, button3.getSelection());
        myModifySettings = new TransformData();
        myModifySettings.setUnmodified();
    }

    private void initGUI() {
        setLayout(new GridLayout());
        composite0 = new Composite(this, SWT.NONE);
        composite0.setLayout(new GridLayout(2, false));
        composite0.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
        textloader = new TextLoadController(composite0, this, SWT.NONE, true, true);
        textloader.addObserver(new Observer() {

            @Override
            public void update(Observable o, Object arg) {
                if (textloader.getText() != null) {
                    myGraph.getFrequencyGraph().setInstruction(Messages.FreqAnalysisGraph_graph1);
                    myGraph.redraw();
                    if (textloader.getText().getText().length() < simpleFreqAnalysis_text_max_length) {
                        text = textloader.getText().getText();
                        lastSuccessfullLoadedText = textloader.getText();
                        source = textloader.getText();
                    } else {
                        boolean result = MessageDialog.openQuestion(SimpleAnalysisUI.this.getShell(), Messages.SimpleAnalysisUI_warning, Messages.SimpleAnalysisUI_warning_text);
                        if (result) {
                            text = textloader.getText().getText();
                            source = textloader.getText();
                        } else {
                            textloader.setTextData(lastSuccessfullLoadedText, null, true);
                            source = lastSuccessfullLoadedText;
                            return;
                        }
                    }
                    recalcSourceInfo();
                    myGraph.getFrequencyGraph().setInstruction(Messages.FreqAnalysisGraph_shiftgraph0);
                    if (text.equals("") || text == null) {
                        MessageDialog.openInformation(getShell(), Messages.AbstractAnalysisUI_0, Messages.AbstractAnalysisUI_2);
                    } else {
                        recalcGraph();
                    }
                }
            }
        });
        // @Override
        // String line;
        // @Override
        // @Override
        composite1 = new Composite(this, SWT.NONE);
        composite1.setLayout(new GridLayout(2, false));
        composite1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group1 = new Group(composite1, SWT.NONE);
        group1.setLayout(new GridLayout());
        group1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group1.setText(Messages.SimpleAnalysisUI_graphlabel);
        myGraph = new CustomFreqCanvas(group1, SWT.NONE);
        myGraph.setLayout(new GridLayout());
        myGraph.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group4 = new Group(composite1, SWT.NONE);
        group4.setLayout(new GridLayout());
        group4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
        group4.setText(Messages.SimpleAnalysisUI_properties);
        tabFolder1 = new TabFolder(group4, SWT.NONE);
        tabItem1 = new TabItem(tabFolder1, SWT.NONE);
        tabItem1.setText(Messages.FullAnalysisUI_firsttablabel);
        composite3 = new Composite(tabFolder1, SWT.NONE);
        composite3.setLayout(new GridLayout());
        composite3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        tabItem1.setControl(composite3);
        composite2 = new Composite(composite3, SWT.NONE);
        composite2.setLayout(new GridLayout());
        composite2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        button3 = new Button(composite2, SWT.RADIO);
        button3.setText(Messages.SimpleAnalysisUI_monoalphabetic);
        button3.setSelection(true);
        button3.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                polyOnOffSelected(evt);
            }
        });
        button4 = new Button(composite2, SWT.RADIO);
        button4.setText(Messages.SimpleAnalysisUI_polyalphabetic);
        button4.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                polyOnOffSelected(evt);
            }
        });
        Label lblPolyalphabetic = new Label(composite2, SWT.WRAP);
        lblPolyalphabetic.setText(Messages.FullAnalysisUI_6);
        GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
        layoutData.widthHint = 100;
        lblPolyalphabetic.setLayoutData(layoutData);
        group2 = new Group(composite2, SWT.NONE);
        group2.setLayout(new GridLayout(2, false));
        group2.setText(Messages.SimpleAnalysisUI_vigeneresettings);
        spinner1 = new Spinner(group2, SWT.NONE);
        spinner1.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent evt) {
                recalcGraph();
            }
        });
        spinner1.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                changedVigOptions();
            }
        });
        spinner1.setSelection(1);
        label1 = new Label(group2, SWT.NONE);
        label1.setText(Messages.SimpleAnalysisUI_keylength);
        spinner2 = new Spinner(group2, SWT.NONE);
        spinner2.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent evt)

        });
        spinner2.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                changedVigOptions();
            }
        });
        spinner2.setSelection(0);
        label2 = new Label(group2, SWT.NONE);
        label2.setText(Messages.SimpleAnalysisUI_offset);
        // @Override
        tabItem2 = new TabItem(tabFolder1, SWT.NONE);
        tabItem2.setText(Messages.FullAnalysisUI_thirdtablabel);
        composite4 = new Composite(tabFolder1, SWT.NONE);
        composite4.setLayout(new GridLayout());
        tabItem2.setControl(composite4);
        label3 = new Label(composite4, SWT.WRAP);
        GridData layoutData1 = new GridData(SWT.FILL, SWT.FILL, true, false);
        label3.setLayoutData(layoutData1);
        label4 = new Label(composite4, SWT.WRAP);
        GridData layoutData2 = new GridData(SWT.FILL, SWT.FILL, true, false);
        label4.setLayoutData(layoutData2);
        label5 = new Label(composite4, SWT.NONE);
        label5.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        text1 = new Text(composite4, SWT.V_SCROLL | SWT.BORDER | SWT.MULTI | SWT.WRAP);
        text1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        recalcSourceInfo();
        tabFolder1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        tabFolder1.setSelection(0);
        layout();
    }

    /**
     * Method for aggregating information about source text file.
     */
    protected void recalcSourceInfo() {
        if (text == null) {
            label3.setText(Messages.FullAnalysisUI_source + " -");
            label4.setText(Messages.FullAnalysisUI_textlength + " -");
            text1.setText("");
            composite4.layout(new Control[] { label3, label4 });
        } else {
            label3.setText(Messages.FullAnalysisUI_source + " " + source.toString());
            String totalLength = Integer.toString(text.length());
            label4.setText(Messages.FullAnalysisUI_textlength + " " + totalLength);
            label5.setText(Messages.FullAnalysisUI_textexcerpt);
            text1.setText(text.substring(0, (text.length() > 1000) ? 1000 : text.length()) + ((text.length() > 1000) ? "..." : ""));
            text1.setEditable(false);
        }
    }

    /**
     * executes a TextModify Wizard.
     *
     * @param the Settings that have to be displayed at the beginning.
     * @return the selected settings.
     */
    public class FreqAnalysisJob extends BackgroundJob {

        private String text;

        private int myLength;

        private int myOffset;

        private String myOverlayAlphabet;

        public TransformData myModifySettings;

        @Override
        public String name() {
            return "Frequency Analysis";
        }

        @Override
        public IStatus computation(IProgressMonitor monitor) {
            SimpleAnalysisUI.this.return__freqanalysis = new FreqAnalysisCalc(this.text, this.myLength, this.myOffset, this.myModifySettings);
            return Status.OK_STATUS;
        }
    }

    /**
     * frequency analysis main procedure
     */
    @Override
    protected void analyze() {
        FreqAnalysisJob job = new FreqAnalysisJob();
        job.text = text;
        job.myLength = myLength;
        job.myOffset = myOffset;
        job.myModifySettings = myModifySettings;
        job.finalizeListeners.add(status -> {
            getDisplay().syncExec(() -> {
                job.liftNoClickDisplaySynced(getDisplay());
                if (status == Status.OK_STATUS) {
                    myAnalysis = return__freqanalysis;
                    myGraph.setAnalysis(myAnalysis);
                }
            });
        });
        job.imposeNoClickDisplayCurrentShellSynced(getDisplay());
        job.runInBackground();
    }

    /**
     * excludes a control from the Layout calculation
     *
     * @param that
     * @param hideit
     */
    private void hideObject(final Control that, final boolean hideit) {
        GridData GData = (GridData) that.getLayoutData();
        // the (GData != null) test is to work around a NullPointerException (bug #95)
        // happening after one leaves the Frequency Analysis open
        // while closing down JCrypTool, then restarts JCrypTool
        if (GData != null) {
            GData.exclude = true && hideit;
        }
        that.setVisible(true && !hideit);
        Control[] myArray = { that };
        layout(myArray);
    }

    private void polyOnOffSelected(final SelectionEvent evt) {
        hideObject(group2, button3.getSelection());
    }

    private void changedVigOptions() {
        if (spinner1.getSelection() < 1) {
            spinner1.setSelection(1);
        }
        if (spinner2.getSelection() < 0) {
            spinner2.setSelection(0);
        }
        spinner1.setMinimum(1);
        spinner1.setMaximum(999999);
        spinner2.setMinimum(0);
        spinner2.setMaximum(spinner1.getSelection() - 1);
        if (spinner2.getSelection() >= spinner1.getSelection()) {
            spinner2.setSelection(spinner1.getSelection() - 1);
        }
        spinner2.setMaximum(spinner1.getSelection());
    }

    public final void execute(final int keyLength, final int keyPos, final boolean resetShift, final boolean executeCalc) {
        if (keyLength > 0) {
            if (keyLength == 1) {
                button3.setSelection(true);
                button4.setSelection(false);
            } else {
                button3.setSelection(false);
                button4.setSelection(true);
            }
            polyOnOffSelected(null);
            spinner1.setSelection(keyLength);
            changedVigOptions();
            if (keyPos < 0) {
                recalcGraph();
            }
        }
        if (keyPos > -1) {
            spinner2.setSelection(keyPos);
            changedVigOptions();
            recalcGraph();
        }
        if (resetShift) {
            myGraph.getFrequencyGraph().resetDrag();
        }
        if (executeCalc) {
            if (checkEditor()) {
                text = getEditorText();
                recalcGraph();
            }
        }
    }

    public void resetClick() {
        // TODO Auto-generated method stub
    }
}


package org.jcryptool.analysis.freqanalysis.ui;

import java.math.BigInteger;
import java.util.Observable;
import java.util.Observer;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.jcryptool.analysis.freqanalysis.calc.FreqAnalysisCalc;
import org.jcryptool.core.operations.algorithm.classic.textmodify.TransformData;
import org.jcryptool.crypto.ui.background.BackgroundJob;
import org.jcryptool.crypto.ui.textloader.ui.wizard.TextLoadController;
import org.jcryptool.crypto.ui.textsource.TextInputWithSource;

/**
 * @author SLeischnig
 */
public class SimpleAnalysisUI extends AbstractAnalysisUI {

    private Composite composite0;

    private Composite composite1;

    private Group group1;

    private Label label1;

    private Button button4;

    private Composite composite2;

    private Group group4;

    private Label label2;

    private Group group2;

    private Composite composite3;

    private TabFolder tabFolder1;

    private TabItem tabItem1;

    private TabItem tabItem2;

    private Composite composite4;

    private Label label3;

    private Label label4;

    private Label label5;

    private Text text1;

    private TextInputWithSource source;

    private FreqAnalysisCalc myAnalysis;

    TransformData myModifySettings;

    private TextLoadController textloader;

    public FreqAnalysisCalc return__freqanalysis;

    private static final int simpleFreqAnalysis_text_max_length = 999999;

    private TextInputWithSource lastSuccessfullLoadedText;

    public SimpleAnalysisUI(final Composite parent, final int style) {
        super(parent, style);
        initGUI();
        hideObject(group2, button3.getSelection());
        myModifySettings = new TransformData();
        myModifySettings.setUnmodified();
    }

    private void initGUI() {
        setLayout(new GridLayout());
        composite0 = new Composite(this, SWT.NONE);
        composite0.setLayout(new GridLayout(2, false));
        composite0.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
        textloader = new TextLoadController(composite0, this, SWT.NONE, true, true);
        textloader.addObserver(new Observer() {

            @Override
            public void update(Observable o, Object arg) {
                if (textloader.getText() != null) {
                    myGraph.getFrequencyGraph().setInstruction(Messages.FreqAnalysisGraph_graph1);
                    myGraph.redraw();
                    if (textloader.getText().getText().length() < simpleFreqAnalysis_text_max_length) {
                        text = textloader.getText().getText();
                        lastSuccessfullLoadedText = textloader.getText();
                        source = textloader.getText();
                    } else {
                        boolean result = MessageDialog.openQuestion(SimpleAnalysisUI.this.getShell(), Messages.SimpleAnalysisUI_warning, Messages.SimpleAnalysisUI_warning_text);
                        if (result) {
                            text = textloader.getText().getText();
                            source = textloader.getText();
                        } else {
                            textloader.setTextData(lastSuccessfullLoadedText, null, true);
                            source = lastSuccessfullLoadedText;
                            return;
                        }
                    }
                    recalcSourceInfo();
                    myGraph.getFrequencyGraph().setInstruction(Messages.FreqAnalysisGraph_shiftgraph0);
                    if (text.equals("") || text == null) {
                        MessageDialog.openInformation(getShell(), Messages.AbstractAnalysisUI_0, Messages.AbstractAnalysisUI_2);
                    } else {
                        recalcGraph();
                    }
                }
            }
        });
        // @Override
        // String line;
        // @Override
        // @Override
        composite1 = new Composite(this, SWT.NONE);
        composite1.setLayout(new GridLayout(2, false));
        composite1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group1 = new Group(composite1, SWT.NONE);
        group1.setLayout(new GridLayout());
        group1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group1.setText(Messages.SimpleAnalysisUI_graphlabel);
        myGraph = new CustomFreqCanvas(group1, SWT.NONE);
        myGraph.setLayout(new GridLayout());
        myGraph.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        group4 = new Group(composite1, SWT.NONE);
        group4.setLayout(new GridLayout());
        group4.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
        group4.setText(Messages.SimpleAnalysisUI_properties);
        tabFolder1 = new TabFolder(group4, SWT.NONE);
        tabItem1 = new TabItem(tabFolder1, SWT.NONE);
        tabItem1.setText(Messages.FullAnalysisUI_firsttablabel);
        composite3 = new Composite(tabFolder1, SWT.NONE);
        composite3.setLayout(new GridLa

        composite3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        tabItem1.setControl(composite3);
        composite2 = new Composite(composite3, SWT.NONE);
        composite2.setLayout(new GridLayout());
        composite2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        button3 = new Button(composite2, SWT.RADIO);
        button3.setText(Messages.SimpleAnalysisUI_monoalphabetic);
        button3.setSelection(true);
        button3.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                polyOnOffSelected(evt);
            }
        });
        button4 = new Button(composite2, SWT.RADIO);
        button4.setText(Messages.SimpleAnalysisUI_polyalphabetic);
        button4.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                polyOnOffSelected(evt);
            }
        });
        Label lblPolyalphabetic = new Label(composite2, SWT.WRAP);
        lblPolyalphabetic.setText(Messages.FullAnalysisUI_6);
        GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
        layoutData.widthHint = 100;
        lblPolyalphabetic.setLayoutData(layoutData);
        group2 = new Group(composite2, SWT.NONE);
        group2.setLayout(new GridLayout(2, false));
        group2.setText(Messages.SimpleAnalysisUI_vigeneresettings);
        spinner1 = new Spinner(group2, SWT.NONE);
        spinner1.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent evt) {
                recalcGraph();
            }
        });
        spinner1.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                changedVigOptions();
            }
        });
        spinner1.setSelection(1);
        label1 = new Label(group2, SWT.NONE);
        label1.setText(Messages.SimpleAnalysisUI_keylength);
        spinner2 = new Spinner(group2, SWT.NONE);
        spinner2.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent evt) {
                recalcGraph();
            }
        });
        spinner2.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent evt) {
                changedVigOptions();
            }
        });
        spinner2.setSelection(0);
        label2 = new Label(group2, SWT.NONE);
        label2.setText(Messages.SimpleAnalysisUI_offset);
        // @Override
        tabItem2 = new TabItem(tabFolder1, SWT.NONE);
        tabItem2.setText(Messages.FullAnalysisUI_thirdtablabel);
        composite4 = new Composite(tabFolder1, SWT.NONE);
        composite4.setLayout(new GridLayout());
        tabItem2.setControl(composite4);
        label3 = new Label(composite4, SWT.WRAP);
        GridData layoutData1 = new GridData(SWT.FILL, SWT.FILL, true, false);
        label3.setLayoutData(layoutData1);
        label4 = new Label(composite4, SWT.WRAP);
        GridData layoutData2 = new GridData(SWT.FILL, SWT.FILL, true, false);
        label4.setLayoutData(layoutData2);
        label5 = new Label(composite4, SWT.NONE);
        label5.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        text1 = new Text(composite4, SWT.V_SCROLL | SWT.BORDER | SWT.MULTI | SWT.WRAP);
        text1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        recalcSourceInfo();
        tabFolder1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        tabFolder1.setSelection(0);
        layout();
    }

    /**
     * Method for aggregating information about source text file.
     */
    protected void recalcSourceInfo() {
        if (text == null) {
            label3.setText(Messages.FullAnalysisUI_source + " -");
            label4.setText(Messages.FullAnalysisUI_textlength + " -");
            text1.setText("");
            composite4.layout(new Control[] { label3, label4 });
        } else {
            label3.setText(Messages.FullAnalysisUI_source + " " + source.toString());
            String totalLength = Integer.toString(text.length());
            label4.setText(Messages.FullAnalysisUI_textlength + " " + totalLength);
            label5.setText(Messages.FullAnalysisUI_textexcerpt);
            text1.setText(text.substring(0, (text.length() > 1000) ? 1000 : text.length()) + ((text.length() > 1000) ? "..." : ""));
            text1.setEditable(false);
        }
    }

    /**
     * executes a TextModify Wizard.
     *
     * @param the Settings that have to be displayed at the beginning.
     * @return the selected settings.
     */
    public class FreqAnalysisJob extends BackgroundJob {

        private String text;

        private int myLength;

        private int myOffset;

        private String myOverlayAlphabet;

        public TransformData myModifySettings;

        @Override
        public String name() {
            return "Frequency Analysis";
        }

        @Override
        public IStatus computation(IProgressMonitor monitor) {
            SimpleAnalysisUI.this.return__freqanalysis = new FreqAnalysisCalc(this.text, this.myLength, this.myOffset, this.myModifySettings);
            return Status.OK_STATUS;
        }
    }

    /**
     * frequency analysis main procedure
     */
    @Override
    protected void analyze() {
        FreqAnalysisJob job = new FreqAnalysisJob();
        job.text = text;
        job.myLength = myLength;
        job.myOffset = myOffset;
        job.myModifySettings = myModifySettings;
        job.finalizeListeners.add(status -> {
            getDisplay().syncExec(() -> {
                job.liftNoClickDisplaySynced(getDisplay());
                if (status == Status.OK_STATUS) {
                    myAnalysis = return__freqanalysis;
                    myGraph.setAnalysis(myAnalysis);
                }
            });
        });
        job.imposeNoClickDisplayCurrentShellSynced(getDisplay());
        job.runInBackground();
    }

    /**
     * excludes a control from the Layout calculation
     *
     * @param that
     * @param hideit
     */
    private void hideObject(final Control that, final boolean hideit) {
        GridData GData = (GridData) that.getLayoutData();
        // the (GData != null) test is to work around a NullPointerException (bug #95)
        // happening after one leaves the Frequency Analysis open
        // while closing down JCrypTool, then restarts JCrypTool
        if (GData != null) {
            GData.exclude = true && hideit;
        }
        that.setVisible(true && !hideit);
        Control[] myArray = { that };
        layout(myArray);
    }

    private void polyOnOffSelected(final SelectionEvent evt) {
        hideObject(group2, button3.getSelection());
    }

    private void changedVigOptions() {
        if (spinner1.getSelection() < 1) {
            spinner1.setSelection(1);
        }
        if (spinner2.getSelection() < 0) {
            spinner2.setSelection(0);
        }
        spinner1.setMinimum(1);
        spinner1.setMaximum(999999);
        spinner2.setMinimum(0);
        spinner2.setMaximum(spinner1.getSelection() - 1);
        if (spinner2.getSelection() >= spinner1.getSelection()) {
            spinner2.setSelection(spinner1.getSelection() - 1);
        }
        spinner2.setMaximum(spinner1.getSelection());
    }

    public final void execute(final int keyLength, final int keyPos, final boolean resetShift, final boolean executeCalc) {
        if (keyLength > 0) {
            if (keyLength == 1) {
                button3.setSelection(true);
                button4.setSelection(false);
            } else {
                button3.setSelection(false);
                button4.setSelection(true);
            }
            polyOnOffSelected(null);
            spinner1.setSelection(keyLength);
            changedVigOptions();
            if (keyPos < 0) {
                recalcGraph();
            }
        }
        if (keyPos > -1) {
            spinner2.setSelection(keyPos);
            changedVigOptions();
            recalcGraph();
        }
        if (resetShift) {
            myGraph.getFrequencyGraph().resetDrag();
        }
        if (executeCalc) {
            if (checkEditor()) {
                text = getEditorText();
                recalcGraph();
            }
        }
    }

    public void resetClick() {
        // TODO Auto-generated method stub
    }
}


@Override
                protected IModel<?> getModel(final Object object)

// Project ProjectForge Community Edition
// www.projectforge.org
package org.projectforge.web.core;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.projectforge.business.task.TaskDependentFilter;
import org.projectforge.common.BeanHelper;
import org.projectforge.framework.persistence.api.BaseSearchFilter;
import org.projectforge.framework.persistence.api.ExtendedBaseDO;
import org.projectforge.framework.persistence.api.SearchDao;
import org.projectforge.framework.persistence.api.SearchResultData;
import org.projectforge.framework.persistence.database.StatisticsCache;
import org.projectforge.framework.utils.NumberFormatter;
import org.projectforge.web.registry.WebRegistryEntry;
import org.projectforge.web.wicket.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class SearchAreaPanel extends Panel {

    private static final long serialVersionUID = -4258095807245346743L;

    private static final int MAXIMUM_ENTRIES_WITHOUT_FILTER_SETTINGS = 10000;

    @SpringBean
    private SearchDao searchDao;

    @SpringBean
    private StatisticsCache statisticsCache;

    /**
     * @param page Needed, because in constructor this panel is not yet added to a page.
     * @param id
     * @param filter
     * @param registryEntry the area to show.
     */
    @SuppressWarnings("serial")
    public SearchAreaPanel(final WebPage page, final String id, final SearchPageFilter filter, final WebRegistryEntry webRegistryEntry) {
        super(id);
        final long millis = System.currentTimeMillis();
        final Class<? extends IListPageColumnsCreator<?>> listPageColumnsCreatorClass = webRegistryEntry.getListPageColumnsCreatorClass();
        final IListPageColumnsCreator<?> listPageColumnsCreator = listPageColumnsCreatorClass == null ? null : (IListPageColumnsCreator<?>) BeanHelper.newInstance(listPageColumnsCreatorClass, PageParameters.class, new PageParameters());
        if (listPageColumnsCreator == null) {
            setVisible(false);
            return;
        }
        if (listPageColumnsCreator instanceof AbstractListPage) {
            ((AbstractListPage<?, ?, ?>) listPageColumnsCreator).setCalledBySearchPage(true);
        }
        final Integer number = statisticsCache.getNumberOfEntities(webRegistryEntry.getDOClass());
        final Class<? extends BaseSearchFilter> registeredFilterClass = webRegistryEntry.getSearchFilterClass();
        final boolean isTaskDependentFilter = registeredFilterClass != null && TaskDependentFilter.class.isAssignableFrom(registeredFilterClass);
        if (number > MAXIMUM_ENTRIES_WITHOUT_FILTER_SETTINGS && (filter.getSearchString() == null || filter.getSearchString().length() < 3) && (isTaskDependentFilter == false || filter.getTask() == null) && filter.getStartTimeOfModification() == null && filter.getStopTimeOfModification() == null) {
            // Don't search to large tables if to less filter settings are given.
            setVisible(false);
            return;
        }
        filter.updateUseModificationFilterFlag();
        final BaseSearchFilter baseSearchFilter;
        if (isTaskDependentFilter == true) {
            baseSearchFilter = (BaseSearchFilter) BeanHelper.newInstance(registeredFilterClass, new Class<?>[] { BaseSearchFilter.class }, filter);
            ((TaskDependentFilter) baseSearchFilter).setTaskId(filter.getTaskId());
            baseSearchFilter.copyBaseSearchFieldsFrom(filter);
        } else {
            baseSearchFilter = filter;
        }
        final List<SearchResultData> searchResult = searchDao.getEntries(baseSearchFilter, webRegistryEntry.getDOClass(), webRegistryEntry.getDao());
        boolean hasError = false;
        if (searchResult == null) {
            // An error occured!
            hasError = true;
        } else if (searchResult.size() == 0) {
            // No hits.
            setVisible(false);
            return;
        }
        boolean hasMore = false;
        if (hasError == true) {
            add(WicketUtils.getInvisibleComponent("dataTable"));
        } else {
            final List<ExtendedBaseDO<Integer>> list = new ArrayList<ExtendedBaseDO<Integer>>();
            for (final SearchResultData data : searchResult) {
                if (data.getDataObject() != null) {
                    list.add(data.getDataObject());
                } else {
                    // Empty entry means: more entries found.
                    hasMore = true;
                    break;
                }
            }
            final List<?> columns = listPageColumnsCreator.createColumns(page, false);
            @SuppressWarnings({ "rawtypes", "unchecked" })
            final DataTable<?, String> dataTable = new DefaultDataTable("dataTable", columns, new MySortableDataProvider("NOSORT", SortOrder.DESCENDING) {

                @Override
                public List<?> getList() {
                    return list;
                }

{
                    return new Model((Serializable) object);
                }
            }, filter.getMaxRows());
            add(dataTable);
        }
        final Label hasMoreEntries;
        if (hasError == true) {
            hasMoreEntries = new Label("hasMoreEntries", page.getString("search.error") + " | ");
        } else {
            hasMoreEntries = new Label("hasMoreEntries", page.getString("moreEntriesAvailable") + " | ");
            hasMoreEntries.setVisible(false);
        }
        add(hasMoreEntries);
        Component showMoreEntrieslink = null;
        if (hasMore == true) {
            final int maxRows = filter.getMaxRows();
            if (maxRows < SearchForm.MAX_PAGE_SIZE) {
                showMoreEntrieslink = new Link<Void>("showMoreEntrieslink") {

                    /**
                     * @see org.apache.wicket.markup.html.link.Link#onClick()
                     */
                    @Override
                    public void onClick() {
                        for (final int number : AbstractListForm.PAGE_SIZES) {
                            if (number > maxRows) {
                                filter.setMaxRows(number);
                                break;
                            }
                        }
                        filter.setArea(webRegistryEntry.getId());
                    }
                };
                add(showMoreEntrieslink);
            } else {
                hasMoreEntries.setVisible(true);
            }
        }
        if (showMoreEntrieslink == null) {
            add(new Label("showMoreEntrieslink", "[invisible]").setVisible(false));
        }
        if (listPageColumnsCreator instanceof AbstractListPage<?, ?, ?>) {
            add(new Link<Void>("listPageLink") {

                /**
                 * @see org.apache.wicket.markup.html.link.Link#onClick()
                 */
                @Override
                public void onClick() {
                    final AbstractListPage<?, ?, ?> listPage = (AbstractListPage<?, ?, ?>) listPageColumnsCreator;
                    listPage.copySearchFieldsFrom(filter);
                    setResponsePage(listPage);
                }
            });
        } else {
            add(new Label("listPageLink", "[invisible]").setVisible(false));
        }
        final long duration = System.currentTimeMillis() - millis;
        add(new Label("areaTitle", page.getString(webRegistryEntry.getI18nTitleHeading())));
        add(new Label("timeOfSearch", NumberFormatter.format(duration)));
    }
}


{
                        for (final int number : AbstractListForm.PAGE_SIZES) {
                            if (number > maxRows) {
                                filter.setMaxRows(number);
                                break;
                            }
                        }
                        filter.setArea(webRegistryEntry.getId());
                    }

// Project ProjectForge Community Edition
// www.projectforge.org
package org.projectforge.web.core;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.projectforge.business.task.TaskDependentFilter;
import org.projectforge.common.BeanHelper;
import org.projectforge.framework.persistence.api.BaseSearchFilter;
import org.projectforge.framework.persistence.api.ExtendedBaseDO;
import org.projectforge.framework.persistence.api.SearchDao;
import org.projectforge.framework.persistence.api.SearchResultData;
import org.projectforge.framework.persistence.database.StatisticsCache;
import org.projectforge.framework.utils.NumberFormatter;
import org.projectforge.web.registry.WebRegistryEntry;
import org.projectforge.web.wicket.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class SearchAreaPanel extends Panel {

    private static final long serialVersionUID = -4258095807245346743L;

    private static final int MAXIMUM_ENTRIES_WITHOUT_FILTER_SETTINGS = 10000;

    @SpringBean
    private SearchDao searchDao;

    @SpringBean
    private StatisticsCache statisticsCache;

    /**
     * @param page Needed, because in constructor this panel is not yet added to a page.
     * @param id
     * @param filter
     * @param registryEntry the area to show.
     */
    @SuppressWarnings("serial")
    public SearchAreaPanel(final WebPage page, final String id, final SearchPageFilter filter, final WebRegistryEntry webRegistryEntry) {
        super(id);
        final long millis = System.currentTimeMillis();
        final Class<? extends IListPageColumnsCreator<?>> listPageColumnsCreatorClass = webRegistryEntry.getListPageColumnsCreatorClass();
        final IListPageColumnsCreator<?> listPageColumnsCreator = listPageColumnsCreatorClass == null ? null : (IListPageColumnsCreator<?>) BeanHelper.newInstance(listPageColumnsCreatorClass, PageParameters.class, new PageParameters());
        if (listPageColumnsCreator == null) {
            setVisible(false);
            return;
        }
        if (listPageColumnsCreator instanceof AbstractListPage) {
            ((AbstractListPage<?, ?, ?>) listPageColumnsCreator).setCalledBySearchPage(true);
        }
        final Integer number = statisticsCache.getNumberOfEntities(webRegistryEntry.getDOClass());
        final Class<? extends BaseSearchFilter> registeredFilterClass = webRegistryEntry.getSearchFilterClass();
        final boolean isTaskDependentFilter = registeredFilterClass != null && TaskDependentFilter.class.isAssignableFrom(registeredFilterClass);
        if (number > MAXIMUM_ENTRIES_WITHOUT_FILTER_SETTINGS && (filter.getSearchString() == null || filter.getSearchString().length() < 3) && (isTaskDependentFilter == false || filter.getTask() == null) && filter.getStartTimeOfModification() == null && filter.getStopTimeOfModification() == null) {
            // Don't search to large tables if to less filter settings are given.
            setVisible(false);
            return;
        }
        filter.updateUseModificationFilterFlag();
        final BaseSearchFilter baseSearchFilter;
        if (isTaskDependentFilter == true) {
            baseSearchFilter = (BaseSearchFilter) BeanHelper.newInstance(registeredFilterClass, new Class<?>[] { BaseSearchFilter.class }, filter);
            ((TaskDependentFilter) baseSearchFilter).setTaskId(filter.getTaskId());
            baseSearchFilter.copyBaseSearchFieldsFrom(filter);
        } else {
            baseSearchFilter = filter;
        }
        final List<SearchResultData> searchResult = searchDao.getEntries(baseSearchFilter, webRegistryEntry.getDOClass(), webRegistryEntry.getDao());
        boolean hasError = false;
        if (searchResult == null) {
            // An error occured!
            hasError = true;
        } else if (searchResult.size() == 0) {
            // No hits.
            setVisible(false);
            return;
        }
        boolean hasMore = false;
        if (hasError == true) {
            add(WicketUtils.getInvisibleComponent("dataTable"));
        } else {
            final List<ExtendedBaseDO<Integer>> list = new ArrayList<ExtendedBaseDO<Integer>>();
            for (final SearchResultData data : searchResult) {
                if (data.getDataObject() != null) {
                    list.add(data.getDataObject());
                } else {
                    // Empty entry means: more entries found.
                    hasMore = true;
                    break;
                }
            }
            final List<?> columns = listPageColumnsCreator.createColumns(page, false);
            @SuppressWarnings({ "rawtypes", "unchecked" })
            final DataTable<?, String> dataTable = new DefaultDataTable("dataTable", columns, new MySortableDataProvider("NOSORT", SortOrder.DESCENDING) {

                @Override
                public List<?> getList() {
                    return list;
                }

                @Override
                protected IModel<?> getModel(final Object object) {
                    return new Model((Serializable) object);
                }
            }, filter.getMaxRows());
            add(dataTable);
        }
        final Label hasMoreEntries;
        if (hasError == true) {
            hasMoreEntries = new Label("hasMoreEntries", page.getString("search.error") + " | ");
        } else {
            hasMoreEntries = new Label("hasMoreEntries", page.getString("moreEntriesAvailable") + " | ");
            hasMoreEntries.setVisible(false);
        }
        add(hasMoreEntries);
        Component showMoreEntrieslink = null;
        if (hasMore == true) {
            final int maxRows = filter.getMaxRows();
            if (maxRows < SearchForm.MAX_PAGE_SIZE) {
                showMoreEntrieslink = new Link<Void>("showMoreEntrieslink") {

                    /**
                     * @see org.apache.wicket.markup.html.link.Link#onClick()
                     */
                    @Override
                    public void onClick()

                };
                add(showMoreEntrieslink);
            } else {
                hasMoreEntries.setVisible(true);
            }
        }
        if (showMoreEntrieslink == null) {
            add(new Label("showMoreEntrieslink", "[invisible]").setVisible(false));
        }
        if (listPageColumnsCreator instanceof AbstractListPage<?, ?, ?>) {
            add(new Link<Void>("listPageLink") {

                /**
                 * @see org.apache.wicket.markup.html.link.Link#onClick()
                 */
                @Override
                public void onClick() {
                    final AbstractListPage<?, ?, ?> listPage = (AbstractListPage<?, ?, ?>) listPageColumnsCreator;
                    listPage.copySearchFieldsFrom(filter);
                    setResponsePage(listPage);
                }
            });
        } else {
            add(new Label("listPageLink", "[invisible]").setVisible(false));
        }
        final long duration = System.currentTimeMillis() - millis;
        add(new Label("areaTitle", page.getString(webRegistryEntry.getI18nTitleHeading())));
        add(new Label("timeOfSearch", NumberFormatter.format(duration)));
    }
}


// Project ProjectForge Community Edition
// www.projectforge.org
package org.projectforge.web.core;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.projectforge.business.task.TaskDependentFilter;
import org.projectforge.common.BeanHelper;
import org.projectforge.framework.persistence.api.BaseSearchFilter;
import org.projectforge.framework.persistence.api.ExtendedBaseDO;
import org.projectforge.framework.persistence.api.SearchDao;
import org.projectforge.framework.persistence.api.SearchResultData;
import org.projectforge.framework.persistence.database.StatisticsCache;
import org.projectforge.framework.utils.NumberFormatter;
import org.projectforge.web.registry.WebRegistryEntry;
import org.projectforge.web.wicket.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class SearchAreaPanel extends Panel {

    private static final long serialVersionUID = -4258095807245346743L;

    private static final int MAXIMUM_ENTRIES_WITHOUT_FILTER_SETTINGS = 10000;

    @SpringBean
    private SearchDao searchDao;

    @SpringBean
    private StatisticsCache statisticsCache;

    /**
     * @param page Needed, because in constructor this panel is not yet added to a page.
     * @param id
     * @param filter
     * @param registryEntry the area to show.
     */
    @SuppressWarnings("serial")
    public SearchAreaPanel(final WebPage page, final String id, final SearchPageFilter filter, final WebRegistryEntry webRegistryEntry) {
        super(id);
        final long millis = System.currentTimeMillis();
        final Class<? extends IListPageColumnsCreator<?>> listPageColumnsCreatorClass = webRegistryEntry.getListPageColumnsCreatorClass();
        final IListPageColumnsCreator<?> listPageColumnsCreator = listPageColumnsCreatorClass == null ? null : (IListPageColumnsCreator<?>) BeanHelper.newInstance(listPageColumnsCreatorClass, PageParameters.class, new PageParameters());
        if (listPageColumnsCreator == null) {
            setVisible(false);
            return;
        }
        if (listPageColumnsCreator instanceof AbstractListPage) {
            ((AbstractListPage<?, ?, ?>) listPageColumnsCreator).setCalledBySearchPage(true);
        }
        final Integer number = statisticsCache.getNumberOfEntities(webRegistryEntry.getDOClass());
        final Class<? extends BaseSearchFilter> registeredFilterClass = webRegistryEntry.getSearchFilterClass();
        final boolean isTaskDependentFilter = registeredFilterClass != null && TaskDependentFilter.class.isAssignableFrom(registeredFilterClass);
        if (number > MAXIMUM_ENTRIES_WITHOUT_FILTER_SETTINGS && (filter.getSearchString() == null || filter.getSearchString().length() < 3) && (isTaskDependentFilter == false || filter.getTask() == null) && filter.getStartTimeOfModification() == null && filter.getStopTimeOfModification() == null) {
            // Don't search to large tables if to less filter settings are given.
            setVisible(false);
            return;
        }
        filter.updateUseModificationFilterFlag();
        final BaseSearchFilter baseSearchFilter;
        if (isTaskDependentFilter == true) {
            baseSearchFilter = (BaseSearchFilter) BeanHelper.newInstance(registeredFilterClass, new Class<?>[] { BaseSearchFilter.class }, filter);
            ((TaskDependentFilter) baseSearchFilter).setTaskId(filter.getTaskId());
            baseSearchFilter.copyBaseSearchFieldsFrom(filter);
        } else {
            baseSearchFilter = filter;
        }
        final List<SearchResultData> searchResult = searchDao.getEntries(baseSearchFilter, webRegistryEntry.getDOClass(), webRegistryEntry.getDao());
        boolean hasError = false;
        if (searchResult == null) {
            // An error occured!
            hasError = true;
        } else if (searchResult.size() == 0) {
            // No hits.
            setVisible(false);
            return;
        }
        boolean hasMore = false;
        if (hasError == true) {
            add(WicketUtils.getInvisibleComponent("dataTable"));
        } else {
            final List<ExtendedBaseDO<Integer>> list = new ArrayList<ExtendedBaseDO<Integer>>();
            for (final SearchResultData data : searchResult) {
                if (data.getDataObject() != null) {
                    list.add(data.getDataObject());
                } else {
                    // Empty entry means: more entries found.
                    hasMore = true;
                    break;
                }
            }
            final List<?> columns = listPageColumnsCreator.createColumns(page, false);
            @SuppressWarnings({ "rawtypes", "unchecked" })
            final DataTable<?, String> dataTable = new DefaultDataTable("dataTable", columns, new MySortableDataProvider("NOSORT", SortOrder.DESCENDING) {

                @Override
                public List<?> getList() {
                    return list;
                }

                @Override
                protected IModel<?> getModel(final Object object) {
                    return new Model((Serializable) object);
                }
            }, filter.getMaxRows());
            add(dataTable);
        }
        final Label hasMoreEntries;
        if (hasError == true) {
            hasMoreEntries = new Label("hasMoreEntries", page.getString("search.error") + " | ");
        } else {
            hasMoreEntries = new Label("hasMoreEntries", page.getString("moreEntriesAvailable") + " | ");
            hasMoreEntries.setVisible(false);
        }
        add(hasMoreEntries);
        Component showMoreEntrieslink = null;
        if (hasMore == true) {
            final int maxRows = filter.getMaxRows();
            if (maxRows < SearchForm.MAX_PAGE_SIZE) {
                showMoreEntrieslink = new Link<Void>("showMoreEntrieslink") {

                    /**
                     * @see org.apache.wicket.markup.html.link.Link#onClick()
                     */
                    @Override
                    public void onClick() {
                        for (final int number : AbstractListForm.PAGE_SIZES) {
                            if (number > maxRows) {
                                filter.setMaxRows(number);
                                break;
                            }
                        }
                        filter.setArea(webRegistryEntry.getId());
                    }
                };
                add(showMoreEntrieslink);
            } else {
                hasMoreEntries.setVisible(true);
            }
        }
        if (showMoreEntrieslink == null) {
            add(new Label("showMoreEntrieslink", "[invisible]").setVisible(false));
        }
        if (listPageColumnsCreator instanceof AbstractListPage<?, ?, ?>) {
            add(new Link<Void>("listPageLink") {

                /**
                 * @see org.apache.wicket.markup.html.link.Link#onClick()
                 */
                @Override
                public void onClick() {
                    final AbstractListPage<?, ?, ?> listPage = (AbstractListPage<?, ?, ?>) listPageColumnsCreator;
                    l

                    setResponsePage(listPage);
                }
            });
        } else {
            add(new Label("listPageLink", "[invisible]").setVisible(false));
        }
        final long duration = System.currentTimeMillis() - millis;
        add(new Label("areaTitle", page.getString(webRegistryEntry.getI18nTitleHeading())));
        add(new Label("timeOfSearch", NumberFormatter.format(duration)));
    }
}


@Override
                public void onClick() {
                    final AbstractListPage<?, ?, ?> listPage = (AbstractListPage<?, ?, ?>) listPageColumnsCreator;
                    listPage.copySearchFieldsFrom(filter);
                    setResponsePage(listPage);
                }

// Project ProjectForge Community Edition
// www.projectforge.org
package org.projectforge.web.core;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.projectforge.business.task.TaskDependentFilter;
import org.projectforge.common.BeanHelper;
import org.projectforge.framework.persistence.api.BaseSearchFilter;
import org.projectforge.framework.persistence.api.ExtendedBaseDO;
import org.projectforge.framework.persistence.api.SearchDao;
import org.projectforge.framework.persistence.api.SearchResultData;
import org.projectforge.framework.persistence.database.StatisticsCache;
import org.projectforge.framework.utils.NumberFormatter;
import org.projectforge.web.registry.WebRegistryEntry;
import org.projectforge.web.wicket.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class SearchAreaPanel extends Panel {

    private static final long serialVersionUID = -4258095807245346743L;

    private static final int MAXIMUM_ENTRIES_WITHOUT_FILTER_SETTINGS = 10000;

    @SpringBean
    private SearchDao searchDao;

    @SpringBean
    private StatisticsCache statisticsCache;

    /**
     * @param page Needed, because in constructor this panel is not yet added to a page.
     * @param id
     * @param filter
     * @param registryEntry the area to show.
     */
    @SuppressWarnings("serial")
    public SearchAreaPanel(final WebPage page, final String id, final SearchPageFilter filter, final WebRegistryEntry webRegistryEntry) {
        super(id);
        final long millis = System.currentTimeMillis();
        final Class<? extends IListPageColumnsCreator<?>> listPageColumnsCreatorClass = webRegistryEntry.getListPageColumnsCreatorClass();
        final IListPageColumnsCreator<?> listPageColumnsCreator = listPageColumnsCreatorClass == null ? null : (IListPageColumnsCreator<?>) BeanHelper.newInstance(listPageColumnsCreatorClass, PageParameters.class, new PageParameters());
        if (listPageColumnsCreator == null) {
            setVisible(false);
            return;
        }
        if (listPageColumnsCreator instanceof AbstractListPage) {
            ((AbstractListPage<?, ?, ?>) listPageColumnsCreator).setCalledBySearchPage(true);
        }
        final Integer number = statisticsCache.getNumberOfEntities(webRegistryEntry.getDOClass());
        final Class<? extends BaseSearchFilter> registeredFilterClass = webRegistryEntry.getSearchFilterClass();
        final boolean isTaskDependentFilter = registeredFilterClass != null && TaskDependentFilter.class.isAssignableFrom(registeredFilterClass);
        if (number > MAXIMUM_ENTRIES_WITHOUT_FILTER_SETTINGS && (filter.getSearchString() == null || filter.getSearchString().length() < 3) && (isTaskDependentFilter == false || filter.getTask() == null) && filter.getStartTimeOfModification() == null && filter.getStopTimeOfModification() == null) {
            // Don't search to large tables if to less filter settings are given.
            setVisible(false);
            return;
        }
        filter.updateUseModificationFilterFlag();
        final BaseSearchFilter baseSearchFilter;
        if (isTaskDependentFilter == true) {
            baseSearchFilter = (BaseSearchFilter) BeanHelper.newInstance(registeredFilterClass, new Class<?>[] { BaseSearchFilter.class }, filter);
            ((TaskDependentFilter) baseSearchFilter).setTaskId(filter.getTaskId());
            baseSearchFilter.copyBaseSearchFieldsFrom(filter);
        } else {
            baseSearchFilter = filter;
        }
        final List<SearchResultData> searchResult = searchDao.getEntries(baseSearchFilter, webRegistryEntry.getDOClass(), webRegistryEntry.getDao());
        boolean hasError = false;
        if (searchResult == null) {
            // An error occured!
            hasError = true;
        } else if (searchResult.size() == 0) {
            // No hits.
            setVisible(false);
            return;
        }
        boolean hasMore = false;
        if (hasError == true) {
            add(WicketUtils.getInvisibleComponent("dataTable"));
        } else {
            final List<ExtendedBaseDO<Integer>> list = new ArrayList<ExtendedBaseDO<Integer>>();
            for (final SearchResultData data : searchResult) {
                if (data.getDataObject() != null) {
                    list.add(data.getDataObject());
                } else {
                    // Empty entry means: more entries found.
                    hasMore = true;
                    break;
                }
            }
            final List<?> columns = listPageColumnsCreator.createColumns(page, false);
            @SuppressWarnings({ "rawtypes", "unchecked" })
            final DataTable<?, String> dataTable = new DefaultDataTable("dataTable", columns, new MySortableDataProvider("NOSORT", SortOrder.DESCENDING) {

                @Override
                public List<?> getList() {
                    return list;
                }

                @Override
                protected IModel<?> getModel(final Object object) {
                    return new Model((Serializable) object);
                }
            }, filter.getMaxRows());
            add(dataTable);
        }
        final Label hasMoreEntries;
        if (hasError == true) {
            hasMoreEntries = new Label("hasMoreEntries", page.getString("search.error") + " | ");
        } else {
            hasMoreEntries = new Label("hasMoreEntries", page.getString("moreEntriesAvailable") + " | ");
            hasMoreEntries.setVisible(false);
        }
        add(hasMoreEntries);
        Component showMoreEntrieslink = null;
        if (hasMore == true) {
            final int maxRows = filter.getMaxRows();
            if (maxRows < SearchForm.MAX_PAGE_SIZE) {
                showMoreEntrieslink = new Link<Void>("showMoreEntrieslink") {

                    /**
                     * @see org.apache.wicket.markup.html.link.Link#onClick()
                     */
                    @Override
                    public void onClick() {
                        for (final int number : AbstractListForm.PAGE_SIZES) {
                            if (number > maxRows) {
                                filter.setMaxRows(number);
                                break;
                            }
                        }
                        filter.setArea(webRegistryEntry.getId());
                    }
                };
                add(showMoreEntrieslink);
            } else {
                hasMoreEntries.setVisible(true);
            }
        }
        if (showMoreEntrieslink == null) {
            add(new Label("showMoreEntrieslink", "[invisible]").setVisible(false));
        }
        if (listPageColumnsCreator instanceof AbstractListPage<?, ?, ?>) {
            add(new Link<Void>("listPageLink") {

                /**
                 * @see org.apache.wicket.markup.html.link.Link#onClick()
                 */

            });
        } else {
            add(new Label("listPageLink", "[invisible]").setVisible(false));
        }
        final long duration = System.currentTimeMillis() - millis;
        add(new Label("areaTitle", page.getString(webRegistryEntry.getI18nTitleHeading())));
        add(new Label("timeOfSearch", NumberFormatter.format(duration)));
    }
}


static boolean asciiEqualsIgnoreCase(byte[] a, byte[] b)

package org.teavm.classlib.java.util.jar;

import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;

final class TJarUtils {

    private TJarUtils() {
    }

{
        if (a.length != b.length) {
            return false;
        }
        for (int i = 0; i < a.length; ++i) {
            if (Character.toLowerCase((char) a[i]) != Character.toLowerCase((char) b[i])) {
                return false;
            }
        }
        return true;
    }

    static byte[] readFullyAndClose(InputStream input) throws IOException {
        ByteBuffer result = ByteBuffer.wrap(new byte[Math.min(512, input.available())]);
        while (true) {
            if (result.remaining() == 0) {
                result = ByteBuffer.wrap(Arrays.copyOf(result.array(), result.capacity() * 2));
            }
            int actuallyRead = input.read(result.array(), result.position(), result.remaining());
            if (actuallyRead == -1) {
                break;
            }
            result.position(result.position() + actuallyRead);
        }
        byte[] b = Arrays.copyOf(result.array(), result.position());
        input.close();
        return b;
    }
}


{
        if (a.length != b.length) {
            return false;
        }
        for (int i = 0; i < a.length; ++i) {
            if (Character.toLowerCase((char) a[i]) != Character.toLowerCase((char) b[i])) {
                return false;
            }
        }
        return true;
    }

package org.teavm.classlib.java.util.jar;

import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;

final class TJarUtils {

    private TJarUtils() {
    }

    static boolean asciiEqualsIgnoreCase(byte[] a, byte[] b)

    static byte[] readFullyAndClose(InputStream input) throws IOException {
        ByteBuffer result = ByteBuffer.wrap(new byte[Math.min(512, input.available())]);
        while (true) {
            if (result.remaining() == 0) {
                result = ByteBuffer.wrap(Arrays.copyOf(result.array(), result.capacity() * 2));
            }
            int actuallyRead = input.read(result.array(), result.position(), result.remaining());
            if (actuallyRead == -1) {
                break;
            }
            result.position(result.position() + actuallyRead);
        }
        byte[] b = Arrays.copyOf(result.array(), result.position());
        input.close();
        return b;
    }
}


package org.teavm.classlib.java.util.jar;

import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;

final class TJarUtils {

    private TJarUtils() {
    }

    static boolean asciiEqualsIgnoreCase(byte[] a, byte[] b) {
        if (a.length != b.length) {
            return false;
        }
        for (int i = 0; i < a.length; ++i) {
            if (Character.toLowerCase((char) a[i]) != Character.toLowerCase((char) b[i])) {
                return false;
            }
        }
        return t

    }

    static byte[] readFullyAndClose(InputStream input) throws IOException {
        ByteBuffer result = ByteBuffer.wrap(new byte[Math.min(512, input.available())]);
        while (true) {
            if (result.remaining() == 0) {
                result = ByteBuffer.wrap(Arrays.copyOf(result.array(), result.capacity() * 2));
            }
            int actuallyRead = input.read(result.array(), result.position(), result.remaining());
            if (actuallyRead == -1) {
                break;
            }
            result.position(result.position() + actuallyRead);
        }
        byte[] b = Arrays.copyOf(result.array(), result.position());
        input.close();
        return b;
    }
}


for (int i = 0; i < a.length; ++i) {
            if (Character.toLowerCase((char) a[i]) != Character.toLowerCase((char) b[i])) {
                return false;
            }
        }

package org.teavm.classlib.java.util.jar;

import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;

final class TJarUtils {

    private TJarUtils() {
    }

    static boolean asciiEqualsIgnoreCase(byte[] a, byte[] b) {
        if (a.length != b.length) {
            return false;
        }

        return true;
    }

    static byte[] readFullyAndClose(InputStream input) throws IOException {
        ByteBuffer result = ByteBuffer.wrap(new byte[Math.min(512, input.available())]);
        while (true) {
            if (result.remaining() == 0) {
                result = ByteBuffer.wrap(Arrays.copyOf(result.array(), result.capacity() * 2));
            }
            int actuallyRead = input.read(result.array(), result.position(), result.remaining());
            if (actuallyRead == -1) {
                break;
            }
            result.position(result.position() + actuallyRead);
        }
        byte[] b = Arrays.copyOf(result.array(), result.position());
        input.close();
        return b;
    }
}


while (true) {
            if (result.remaining() == 0) {
                result = ByteBuffer.wrap(Arrays.copyOf(result.array(), result.capacity() * 2));
            }
            int actuallyRead = input.read(result.array(), result.position(), result.remaining());
            if (actuallyRead == -1) {
                break;
            }
            result.position(result.position() + actuallyRead);
        }

package org.teavm.classlib.java.util.jar;

import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;

final class TJarUtils {

    private TJarUtils() {
    }

    static boolean asciiEqualsIgnoreCase(byte[] a, byte[] b) {
        if (a.length != b.length) {
            return false;
        }
        for (int i = 0; i < a.length; ++i) {
            if (Character.toLowerCase((char) a[i]) != Character.toLowerCase((char) b[i])) {
                return false;
            }
        }
        return true;
    }

    static byte[] readFullyAndClose(InputStream input) throws IOException {
        ByteBuffer result = ByteBuffer.wrap(new byte[Math.min(512, input.available())]);

        byte[] b = Arrays.copyOf(result.array(), result.position());
        input.close();
        return b;
    }
}


@Override
    public void generateTestData(ProcessEngine processEngine)

package org.flowable.compatibility.testdata.generator;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.flowable.compatibility.testdata.Flowable5TestDataGenerator;

public class AsyncFailingJobTestDataGenerator implements Flowable5TestDataGenerator {

{
        RepositoryService repositoryService = processEngine.getRepositoryService();
        repositoryService.createDeployment().addClasspathResource("async-failing-expression.bpmn20.xml").deploy();
        RuntimeService runtimeService = processEngine.getRuntimeService();
        runtimeService.startProcessInstanceByKey("asyncFailingExpression");
    }
}


{
        RepositoryService repositoryService = processEngine.getRepositoryService();
        repositoryService.createDeployment().addClasspathResource("async-failing-expression.bpmn20.xml").deploy();
        RuntimeService runtimeService = processEngine.getRuntimeService();
        runtimeService.startProcessInstanceByKey("asyncFailingExpression");
    }

package org.flowable.compatibility.testdata.generator;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.flowable.compatibility.testdata.Flowable5TestDataGenerator;

public class AsyncFailingJobTestDataGenerator implements Flowable5TestDataGenerator {

    @Override
    public void generateTestData(ProcessEngine processEngine)


package org.flowable.compatibility.testdata.generator;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.flowable.compatibility.testdata.Flowable5TestDataGenerator;

public class AsyncFailingJobTestDataGenerator implements Flowable5TestDataGenerator {

    @Override
    public void generateTestData(ProcessEngine processEngine) {
        RepositoryService repositoryService = processEngine.getRepositoryService();
        repositoryService.createDeployment().addClasspathResource("asyn

        RuntimeService runtimeService = processEngine.getRuntimeService();
        runtimeService.startProcessInstanceByKey("asyncFailingExpression");
    }
}


/*
 *
 *
 * For more information, please see http://example.com.
 *
 */
package org.fastquery.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.fastquery.core.RepositoryException;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * @author xixifeng (example@nnthink.com)
 */
public class FastQueryJSONObject {

    private static final String DEBUG = "debug";

    private static JSONObject jo;

    private FastQueryJSONObject() {
    }

    static synchronized void setJsonObject(JSONObject o) {
        if (jo == null) {
            jo = o;
        } else {
            throw new RepositoryException("fastquery.json不能重复装载");
        }
    }

    public static String getBasedir() {
        return jo.getString("basedir");
    }

    public static boolean getDebug() {
        return (boolean) jo.getOrDefault(DEBUG, false);
    }

    public static List<String> getQueries() {
        List<String> strs = new ArrayList<>();
        JSONArray jsonArray = jo.getJSONArray("queries");
        if (jsonArray == null) {
            return strs;
        }
        jsonArray.forEach(s -> strs.add(s.toString()));
        return strs;
    }

{
        return jo.getIntValue("slowQueryTime");
    }

    static void check() {
        List<String> strs = getQueries();
        for (String str : strs) {
            if (StringUtils.EMPTY.equals(str)) {
                continue;
            }
            if (str.charAt(0) == '/') {
                throw new RepositoryException(String.format("fastquery.json-> queries配置错误,\"%s\"的开头不应该有\"/\"", str));
            }
            if (str.charAt(str.length() - 1) != '/') {
                throw new RepositoryException(String.format("fastquery.json-> queries配置错误,\"%s\"的末尾必须加\"/\"", str));
            }
        }
        if (jo.containsKey(DEBUG)) {
            Object debug = jo.get(DEBUG);
            if (!(debug instanceof Boolean)) {
                throw new RepositoryException("fastquery.json -> debug 它的值只能是true或false,也可以不用配置,要配,请配置正确");
            }
        }
        String slowQueryTime = jo.getString("slowQueryTime");
        if (slowQueryTime != null && !Pattern.matches("\\d+", slowQueryTime)) {
            throw new RepositoryException("fastquery.json -> slowQueryTime 它的值只能是数字");
        }
    }
}


{
        if (jo == null) {
            jo = o;
        } else {
            throw new RepositoryException("fastquery.json不能重复装载");
        }
    }

/*
 *
 *
 * For more information, please see http://example.com.
 *
 */
package org.fastquery.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.fastquery.core.RepositoryException;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * @author xixifeng (example@nnthink.com)
 */
public class FastQueryJSONObject {

    private static final String DEBUG = "debug";

    private static JSONObject jo;

    private FastQueryJSONObject() {
    }

    static synchronized void setJsonObject(JSONObject o)

    public static String getBasedir() {
        return jo.getString("basedir");
    }

    public static boolean getDebug() {
        return (boolean) jo.getOrDefault(DEBUG, false);
    }

    public static List<String> getQueries() {
        List<String> strs = new ArrayList<>();
        JSONArray jsonArray = jo.getJSONArray("queries");
        if (jsonArray == null) {
            return strs;
        }
        jsonArray.forEach(s -> strs.add(s.toString()));
        return strs;
    }

    public static int getSlowQueryTime() {
        return jo.getIntValue("slowQueryTime");
    }

    static void check() {
        List<String> strs = getQueries();
        for (String str : strs) {
            if (StringUtils.EMPTY.equals(str)) {
                continue;
            }
            if (str.charAt(0) == '/') {
                throw new RepositoryException(String.format("fastquery.json-> queries配置错误,\"%s\"的开头不应该有\"/\"", str));
            }
            if (str.charAt(str.length() - 1) != '/') {
                throw new RepositoryException(String.format("fastquery.json-> queries配置错误,\"%s\"的末尾必须加\"/\"", str));
            }
        }
        if (jo.containsKey(DEBUG)) {
            Object debug = jo.get(DEBUG);
            if (!(debug instanceof Boolean)) {
                throw new RepositoryException("fastquery.json -> debug 它的值只能是true或false,也可以不用配置,要配,请配置正确");
            }
        }
        String slowQueryTime = jo.getString("slowQueryTime");
        if (slowQueryTime != null && !Pattern.matches("\\d+", slowQueryTime)) {
            throw new RepositoryException("fastquery.json -> slowQueryTime 它的值只能是数字");
        }
    }
}


/*
 *
 *
 * For more information, please see http://example.com.
 *
 */
package org.fastquery.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.fastquery.core.RepositoryException;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * @author xixifeng (example@nnthink.com)
 */
public class FastQueryJSONObject {

    private static final String DEBUG = "debug";

    private static JSONObject jo;

    private FastQueryJSONObject() {
    }

    static synchronized void setJsonObject(JSONObject o) {
        if (jo == null) {
            jo = o;
        } else {
            throw new RepositoryException("fastquery.json不能重复装载");
        }
    }

    public static String getBasedir() {
        return jo.ge

    }

    public static boolean getDebug() {
        return (boolean) jo.getOrDefault(DEBUG, false);
    }

    public static List<String> getQueries() {
        List<String> strs = new ArrayList<>();
        JSONArray jsonArray = jo.getJSONArray("queries");
        if (jsonArray == null) {
            return strs;
        }
        jsonArray.forEach(s -> strs.add(s.toString()));
        return strs;
    }

    public static int getSlowQueryTime() {
        return jo.getIntValue("slowQueryTime");
    }

    static void check() {
        List<String> strs = getQueries();
        for (String str : strs) {
            if (StringUtils.EMPTY.equals(str)) {
                continue;
            }
            if (str.charAt(0) == '/') {
                throw new RepositoryException(String.format("fastquery.json-> queries配置错误,\"%s\"的开头不应该有\"/\"", str));
            }
            if (str.charAt(str.length() - 1) != '/') {
                throw new RepositoryException(String.format("fastquery.json-> queries配置错误,\"%s\"的末尾必须加\"/\"", str));
            }
        }
        if (jo.containsKey(DEBUG)) {
            Object debug = jo.get(DEBUG);
            if (!(debug instanceof Boolean)) {
                throw new RepositoryException("fastquery.json -> debug 它的值只能是true或false,也可以不用配置,要配,请配置正确");
            }
        }
        String slowQueryTime = jo.getString("slowQueryTime");
        if (slowQueryTime != null && !Pattern.matches("\\d+", slowQueryTime)) {
            throw new RepositoryException("fastquery.json -> slowQueryTime 它的值只能是数字");
        }
    }
}


package com.jpexs.decompiler.flash.types;

import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.exporters.shape.PathExporter;
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
import com.jpexs.decompiler.flash.types.annotations.SWFArray;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.shaperecords.EndShapeRecord;
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
import java.awt.Shape;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * @author JPEXS
 */
public class SHAPE implements NeedsCharacters, Serializable {

    @SWFType(value = BasicType.UB, count = 4)
    public int numFillBits;

    @SWFType(value = BasicType.UB, count = 4)
    public int numLineBits;

    @SWFArray(value = "record")
    public List<SHAPERECORD> shapeRecords;

    private Shape cachedOutline;

    @Override
    public void getNeededCharacters(Set<Integer> needed) {
        for (SHAPERECORD r : shapeRecords) {
            r.getNeededCharacters(needed);
        }
    }

    @Override
    public boolean replaceCharacter(int oldCharacterId, int newCharacterId) {
        boolean modified = false;
        for (SHAPERECORD r : shapeRecords) {
            modified |= r.replaceCharacter(oldCharacterId, newCharacterId);
        }
        return modified;
    }

    @Override
    public boolean removeCharacter(int characterId) {
        boolean modified = false;
        for (SHAPERECORD r : shapeRecords) {
            modified |= r.removeCharacter(characterId);
        }
        return modified;
    }

    public RECT getBounds() {
        return SHAPERECORD.getBounds(shapeRecords);
    }

    public Shape getOutline(SWF swf, boolean stroked) {
        if (cachedOutline != null) {
            return cachedOutline;
        }
        List<GeneralPath> strokes = new ArrayList<>();
        List<GeneralPath> paths = PathExporter.export(swf, this, strokes);
        Area area = new Area();
        for (GeneralPath path : paths) {
            area.add(new Area(path));
        }
        if (stroked) {
            for (GeneralPath path : strokes) {
                area.add(new Area(path));
            }
        }
        cachedOutline = area;
        return area;
    }

{
        return resize(multiplier, multiplier);
    }

    public SHAPE resize(double multiplierX, double multiplierY) {
        SHAPE ret = new SHAPE();
        ret.numFillBits = numFillBits;
        ret.numLineBits = numLineBits;
        List<SHAPERECORD> recs = new ArrayList<>();
        for (SHAPERECORD r : shapeRecords) {
            SHAPERECORD c = r.resize(multiplierX, multiplierY);
            recs.add(c);
        }
        ret.shapeRecords = recs;
        return ret;
    }

    public static SHAPE createEmpty(int shapeNum) {
        SHAPE ret = new SHAPE();
        ret.shapeRecords = new ArrayList<>();
        ret.shapeRecords.add(new EndShapeRecord());
        return ret;
    }
}