Search in sources :

Example 91 with ActionEvent

use of java.awt.event.ActionEvent in project zaproxy by zaproxy.

the class ExtensionAutoUpdate method getOutOfDateButton.

private JButton getOutOfDateButton() {
    if (outOfDateButton == null) {
        outOfDateButton = new JButton(Constant.messages.getString("cfu.label.outofdateaddons"));
        outOfDateButton.setIcon(new ImageIcon(// Alert triangle
        ExtensionAutoUpdate.class.getResource("/resource/icon/16/050.png")));
        outOfDateButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                alertIfOutOfDate(true);
            }
        });
    }
    return outOfDateButton;
}
Also used : ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton)

Example 92 with ActionEvent

use of java.awt.event.ActionEvent in project zaproxy by zaproxy.

the class ExtensionAutoUpdate method alertIfOutOfDate.

private void alertIfOutOfDate(boolean alwaysPrompt) {
    final OptionsParamCheckForUpdates options = getModel().getOptionsParam().getCheckForUpdatesParam();
    Date today = new Date();
    Date releaseCreated = Constant.getReleaseCreateDate();
    Date lastInstallWarning = options.getDayLastInstallWarned();
    int result = -1;
    logger.debug("Install created " + releaseCreated);
    if (releaseCreated != null) {
        // Should only be null for dev builds
        int daysOld = dayDiff(today, releaseCreated);
        logger.debug("Install is " + daysOld + " days old");
        if (daysOld > 365) {
            // Oh no, its more than a year old!
            boolean setCfuOnStart = false;
            if (alwaysPrompt || lastInstallWarning == null || dayDiff(today, lastInstallWarning) > 30) {
                JCheckBox cfuOnStart = new JCheckBox(Constant.messages.getString("cfu.label.cfuonstart"));
                cfuOnStart.setSelected(true);
                String msg = Constant.messages.getString("cfu.label.oldzap");
                result = View.getSingleton().showYesNoDialog(View.getSingleton().getMainFrame(), new Object[] { msg, cfuOnStart });
                setCfuOnStart = cfuOnStart.isSelected();
            }
            options.setDayLastInstallWarned();
            if (result == JOptionPane.OK_OPTION) {
                if (setCfuOnStart) {
                    options.setCheckOnStart(true);
                }
                getAddOnsDialog().setVisible(true);
                getAddOnsDialog().checkForUpdates();
            } else if (!oldZapAlertAdded) {
                JButton button = new JButton(Constant.messages.getString("cfu.label.outofdatezap"));
                button.setIcon(new ImageIcon(// Alert triangle
                ExtensionAutoUpdate.class.getResource("/resource/icon/16/050.png")));
                button.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        alertIfOutOfDate(true);
                    }
                });
                View.getSingleton().getMainFrame().getMainFooterPanel().addFooterToolbarLeftComponent(button);
                oldZapAlertAdded = true;
            }
            return;
        }
    }
    Date lastChecked = options.getDayLastChecked();
    Date lastUpdateWarning = options.getDayLastUpdateWarned();
    Date installDate = Constant.getInstallDate();
    if (installDate == null || dayDiff(today, installDate) < 90) {
    // Dont warn if installed in the last 3 months
    } else if (lastChecked == null || dayDiff(today, lastChecked) > 90) {
        // Not checked for updates in 3 months :(
        boolean setCfuOnStart = false;
        if (alwaysPrompt || lastUpdateWarning == null || dayDiff(today, lastUpdateWarning) > 30) {
            JCheckBox cfuOnStart = new JCheckBox(Constant.messages.getString("cfu.label.cfuonstart"));
            cfuOnStart.setSelected(true);
            String msg = Constant.messages.getString("cfu.label.norecentcfu");
            result = View.getSingleton().showYesNoDialog(View.getSingleton().getMainFrame(), new Object[] { msg, cfuOnStart });
            setCfuOnStart = cfuOnStart.isSelected();
        }
        options.setDayLastUpdateWarned();
        if (result == JOptionPane.OK_OPTION) {
            if (setCfuOnStart) {
                options.setCheckOnStart(true);
            }
            getAddOnsDialog().setVisible(true);
            getAddOnsDialog().checkForUpdates();
            if (noCfuAlertAdded) {
                View.getSingleton().getMainFrame().getMainFooterPanel().removeFooterToolbarLeftComponent(getOutOfDateButton());
            }
        } else if (!noCfuAlertAdded) {
            View.getSingleton().getMainFrame().getMainFooterPanel().addFooterToolbarLeftComponent(getOutOfDateButton());
            noCfuAlertAdded = true;
        }
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Date(java.util.Date)

Example 93 with ActionEvent

use of java.awt.event.ActionEvent in project freeline by alibaba.

the class UpdateAction method resultHandle.

/**
     * 处理结果
     *
     * @param entity
     * @param gradleBuildModels
     */
private void resultHandle(final GradleDependencyEntity entity, final Map<GradleBuildModel, List<ArtifactDependencyModel>> gradleBuildModels) {
    String localVersion = null;
    StringBuilder builder = new StringBuilder();
    for (GradleBuildModel file : gradleBuildModels.keySet()) {
        List<ArtifactDependencyModel> models = gradleBuildModels.get(file);
        for (ArtifactDependencyModel dependencyModel1 : models) {
            ArtifactDependencyModelWrapper dependencyModel = new ArtifactDependencyModelWrapper(dependencyModel1);
            if (isClasspathLibrary(dependencyModel) || isDependencyLibrary(dependencyModel)) {
                if (isClasspathLibrary(dependencyModel)) {
                    localVersion = dependencyModel.version();
                }
                builder.append(dependencyModel.configurationName()).append(" '").append(dependencyModel.group()).append(":").append(dependencyModel.name()).append(":").append(dependencyModel.version()).append("'").append("<br/>");
            }
        }
    }
    if (Utils.notEmpty(localVersion)) {
        int compare = localVersion.compareTo(entity.getVersion());
        final CheckUpdateDialog dialog = new CheckUpdateDialog();
        dialog.getButtonOK().setEnabled(compare < 0);
        dialog.setServerVersion(entity.getGroupId(), entity.getArtifactId(), entity.getVersion());
        dialog.setServerUpdateTime(entity.getUpdateTime());
        dialog.setLocalVersion(builder.toString());
        dialog.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                updateAction(entity.getVersion(), gradleBuildModels);
                dialog.dispose();
            }
        });
        dialog.showDialog();
    } else {
        NotificationUtils.infoNotification("please add freeline dependency first");
    }
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ArtifactDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel) CheckUpdateDialog(com.antfortune.freeline.idea.views.CheckUpdateDialog) ArtifactDependencyModelWrapper(com.antfortune.freeline.idea.models.ArtifactDependencyModelWrapper)

Example 94 with ActionEvent

use of java.awt.event.ActionEvent in project freeline by alibaba.

the class UsingReportAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getProject();
    Module[] modules = ModuleManager.getInstance(project).getModules();
    List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>();
    for (Module module : modules) {
        GradleBuildFile file = GradleBuildFile.get(module);
        if (file != null && !GradleUtil.isLibrary(file)) {
            selectModulesList.add(Pair.create(module, file.getPsiFile()));
        }
    }
    if (selectModulesList.size() > 1) {
        final DialogBuilder builder = new DialogBuilder();
        builder.setTitle("Freeline Reporter");
        builder.resizable(false);
        builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the exact one.", Messages.getInformationIcon(), SwingConstants.CENTER));
        builder.addOkAction().setText("Cancel");
        for (final Pair<Module, PsiFile> pair : selectModulesList) {
            builder.addAction(new AbstractAction(":" + pair.first.getName()) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
                    report(project, pair.getSecond());
                }
            });
        }
        if (builder.show() > -1) {
        //return false;
        }
    } else if (selectModulesList.size() == 1) {
        report(project, selectModulesList.get(0).getSecond());
    }
}
Also used : GradleBuildFile(com.android.tools.idea.gradle.parser.GradleBuildFile) ActionEvent(java.awt.event.ActionEvent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ArrayList(java.util.ArrayList) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) Pair(com.intellij.openapi.util.Pair)

Example 95 with ActionEvent

use of java.awt.event.ActionEvent in project processing by processing.

the class Base method populateToolsMenu.

public void populateToolsMenu(JMenu toolsMenu) {
    // If this is the first run, need to build out the lists
    if (internalTools == null) {
        rebuildToolList();
    }
    //    coreTools = ToolContribution.loadAll(Base.getToolsFolder());
    //    contribTools = ToolContribution.loadAll(Base.getSketchbookToolsFolder());
    //    Collections.sort(coreTools);
    //    Collections.sort(contribTools);
    //    Collections.sort(coreTools, new Comparator<ToolContribution>() {
    //      @Override
    //      public int compare(ToolContribution o1, ToolContribution o2) {
    //        return o1.getMenuTitle().compareTo(o2.getMenuTitle());
    //      }
    //    });
    toolsMenu.removeAll();
    for (Tool tool : internalTools) {
        toolsMenu.add(createToolItem(tool));
    }
    toolsMenu.addSeparator();
    if (coreTools.size() > 0) {
        for (Tool tool : coreTools) {
            toolsMenu.add(createToolItem(tool));
        }
        toolsMenu.addSeparator();
    }
    if (contribTools.size() > 0) {
        for (Tool tool : contribTools) {
            toolsMenu.add(createToolItem(tool));
        }
        toolsMenu.addSeparator();
    }
    JMenuItem item = new JMenuItem(Language.text("menu.tools.add_tool"));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            ContributionManager.openTools();
        }
    });
    toolsMenu.add(item);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) Tool(processing.app.tools.Tool)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1619 ActionListener (java.awt.event.ActionListener)1289 JButton (javax.swing.JButton)417 JPanel (javax.swing.JPanel)391 JLabel (javax.swing.JLabel)253 JMenuItem (javax.swing.JMenuItem)219 BoxLayout (javax.swing.BoxLayout)172 AbstractAction (javax.swing.AbstractAction)166 FlowLayout (java.awt.FlowLayout)130 Insets (java.awt.Insets)129 GridBagConstraints (java.awt.GridBagConstraints)127 Dimension (java.awt.Dimension)126 GridBagLayout (java.awt.GridBagLayout)120 JMenu (javax.swing.JMenu)118 JScrollPane (javax.swing.JScrollPane)117 JCheckBox (javax.swing.JCheckBox)109 BorderLayout (java.awt.BorderLayout)108 JTextField (javax.swing.JTextField)85 JComboBox (javax.swing.JComboBox)77 ButtonGroup (javax.swing.ButtonGroup)72