Search in sources :

Example 1 with StrategyInjectionError

use of com.jsql.model.injection.strategy.StrategyInjectionError in project jsql-injection by ron190.

the class ManagerDatabase method initErrorMethods.

public void initErrorMethods(Vendor vendor) {
    this.itemRadioStrategyError[0].removeAll();
    Integer[] i = { 0 };
    if (vendor != Vendor.AUTO && vendor.instance().getXmlModel().getStrategy().getError() != null) {
        for (Method methodError : vendor.instance().getXmlModel().getStrategy().getError().getMethod()) {
            JMenuItem itemRadioVendor = new JRadioButtonMenuItem(methodError.getName());
            itemRadioVendor.setEnabled(false);
            this.itemRadioStrategyError[0].add(itemRadioVendor);
            this.groupStrategy.add(itemRadioVendor);
            final int indexError = i[0];
            itemRadioVendor.addActionListener(actionEvent -> {
                ManagerDatabase.this.menuStrategy.setText(methodError.getName());
                MediatorModel.model().setStrategy(StrategyInjection.ERROR);
                ((StrategyInjectionError) StrategyInjection.ERROR.instance()).setIndexMethod(indexError);
            });
            i[0]++;
        }
    }
}
Also used : StrategyInjectionError(com.jsql.model.injection.strategy.StrategyInjectionError) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Method(com.jsql.model.injection.vendor.model.Model.Strategy.Error.Method) JMenuItem(javax.swing.JMenuItem)

Example 2 with StrategyInjectionError

use of com.jsql.model.injection.strategy.StrategyInjectionError in project jsql-injection by ron190.

the class AddressMenuBar method markError.

public void markError() {
    StrategyInjectionError strategy = MediatorHelper.model().getMediatorStrategy().getError();
    this.menuStrategy.setText(strategy.toString());
    JMenu menuError = this.getMenuError();
    int indexError = strategy.getIndexErrorStrategy();
    String nameError = MediatorHelper.model().getMediatorVendor().getVendor().instance().getModelYaml().getStrategy().getError().getMethod().get(indexError).getName();
    for (var i = 0; i < menuError.getItemCount(); i++) {
        // Fix #44635: ArrayIndexOutOfBoundsException on getItem()
        try {
            if (menuError.getItem(i).getText().equals(nameError)) {
                menuError.getItem(i).setSelected(true);
                this.menuStrategy.setText(nameError);
                break;
            }
        } catch (NullPointerException | ArrayIndexOutOfBoundsException e) {
            LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
        }
    }
}
Also used : StrategyInjectionError(com.jsql.model.injection.strategy.StrategyInjectionError) JMenu(javax.swing.JMenu)

Aggregations

StrategyInjectionError (com.jsql.model.injection.strategy.StrategyInjectionError)2 Method (com.jsql.model.injection.vendor.model.Model.Strategy.Error.Method)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1