Search in sources :

Example 1 with View

use of org.parosproxy.paros.view.View in project zaproxy by zaproxy.

the class PolicyPassiveScanPanel method getApplyToThresholdTarget.

private JComboBox<String> getApplyToThresholdTarget() {
    if (applyToThresholdTarget == null) {
        applyToThresholdTarget = new JComboBox<>();
        applyToThresholdTarget.addItem(Constant.messages.getString("ascan.policy.table.quality.all"));
        View view = View.getSingleton();
        applyToThresholdTarget.addItem(view.getStatusUI(AddOn.Status.release).toString());
        applyToThresholdTarget.addItem(view.getStatusUI(AddOn.Status.beta).toString());
        applyToThresholdTarget.addItem(view.getStatusUI(AddOn.Status.alpha).toString());
    }
    return applyToThresholdTarget;
}
Also used : View(org.parosproxy.paros.view.View)

Example 2 with View

use of org.parosproxy.paros.view.View in project zaproxy by zaproxy.

the class GuiBootstrap method initControlAndPostViewInit.

/**
 * Initialises the {@code Control} and does post {@code View} initialisations.
 *
 * @throws Exception if an error occurs during initialisation
 * @see Control
 * @see View
 */
private void initControlAndPostViewInit() throws Exception {
    Control.initSingletonWithView(getControlOverrides());
    final Control control = Control.getSingleton();
    final View view = View.getSingleton();
    EventQueue.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            view.postInit();
            view.getMainFrame().setVisible(true);
            boolean createNewSession = true;
            if (getArgs().isEnabled(CommandLine.SESSION) && getArgs().isEnabled(CommandLine.NEW_SESSION)) {
                view.showWarningDialog(Constant.messages.getString("start.gui.cmdline.invalid.session.options", CommandLine.SESSION, CommandLine.NEW_SESSION, Constant.getZapHome()));
            } else if (getArgs().isEnabled(CommandLine.SESSION)) {
                Path sessionPath = SessionUtils.getSessionPath(getArgs().getArgument(CommandLine.SESSION));
                if (!Files.exists(sessionPath)) {
                    view.showWarningDialog(Constant.messages.getString("start.gui.cmdline.session.does.not.exist", Constant.getZapHome()));
                } else {
                    createNewSession = !control.getMenuFileControl().openSession(sessionPath.toAbsolutePath().toString());
                }
            } else if (getArgs().isEnabled(CommandLine.NEW_SESSION)) {
                Path sessionPath = SessionUtils.getSessionPath(getArgs().getArgument(CommandLine.NEW_SESSION));
                if (Files.exists(sessionPath)) {
                    view.showWarningDialog(Constant.messages.getString("start.gui.cmdline.newsession.already.exist", Constant.getZapHome()));
                } else {
                    createNewSession = !control.getMenuFileControl().newSession(sessionPath.toAbsolutePath().toString());
                }
            }
            view.hideSplashScreen();
            if (createNewSession) {
                try {
                    control.getMenuFileControl().newSession(false);
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                    View.getSingleton().showWarningDialog(Constant.messages.getString("menu.file.newSession.error"));
                }
            }
        }
    });
    try {
        // Allow extensions to pick up command line args in GUI mode
        control.getExtensionLoader().hookCommandLineListener(getArgs());
        control.runCommandLine();
    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                view.showWarningDialog(e.getMessage());
            }
        });
    }
}
Also used : Path(java.nio.file.Path) Control(org.parosproxy.paros.control.Control) OptionsParamView(org.parosproxy.paros.extension.option.OptionsParamView) View(org.parosproxy.paros.view.View) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) FileNotFoundException(java.io.FileNotFoundException) ConfigurationException(org.apache.commons.configuration.ConfigurationException)

Example 3 with View

use of org.parosproxy.paros.view.View in project zaproxy by zaproxy.

the class PolicyAllCategoryPanel method createStatusComboBox.

/**
 * Creates a {@code JComboBox} with scanners' statuses, "all", release, beta and alpha.
 *
 * @return a {@code JComboBox} with scanners' statuses
 */
private JComboBox<String> createStatusComboBox() {
    JComboBox<String> comboBox = new JComboBox<>();
    comboBox.addItem(Constant.messages.getString("ascan.policy.table.quality.all"));
    View view = View.getSingleton();
    comboBox.addItem(view.getStatusUI(AddOn.Status.release).toString());
    comboBox.addItem(view.getStatusUI(AddOn.Status.beta).toString());
    comboBox.addItem(view.getStatusUI(AddOn.Status.alpha).toString());
    return comboBox;
}
Also used : JComboBox(javax.swing.JComboBox) View(org.parosproxy.paros.view.View)

Example 4 with View

use of org.parosproxy.paros.view.View in project zaproxy by zaproxy.

the class ExtensionLoaderUnitTest method shouldInitViewWhenStartingExtensionWithView.

@Test
void shouldInitViewWhenStartingExtensionWithView() throws Exception {
    // Given
    View view = mock(View.class);
    extensionLoader = new ExtensionLoader(model, view);
    Extension extension = mock(Extension.class);
    // When
    extensionLoader.startLifeCycle(extension);
    // Then
    verify(extension).initView(view);
}
Also used : View(org.parosproxy.paros.view.View) Test(org.junit.jupiter.api.Test)

Aggregations

View (org.parosproxy.paros.view.View)4 FileNotFoundException (java.io.FileNotFoundException)1 Path (java.nio.file.Path)1 JComboBox (javax.swing.JComboBox)1 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 Test (org.junit.jupiter.api.Test)1 Control (org.parosproxy.paros.control.Control)1 OptionsParamView (org.parosproxy.paros.extension.option.OptionsParamView)1