Search in sources :

Example 81 with ActionListener

use of java.awt.event.ActionListener 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 82 with ActionListener

use of java.awt.event.ActionListener 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)

Example 83 with ActionListener

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

the class Recent method updateMenuRecord.

private static void updateMenuRecord(JMenu menu, final Record rec, String sketchbookPath) {
    try {
        String recPath = new File(rec.getPath()).getParent();
        String purtyPath = null;
        if (recPath.startsWith(sketchbookPath)) {
            purtyPath = "sketchbook → " + recPath.substring(sketchbookPath.length() + 1);
        } else {
            List<Mode> modes = base.getModeList();
            for (Mode mode : modes) {
                File examplesFolder = mode.getExamplesFolder();
                String examplesPath = examplesFolder.getAbsolutePath();
                if (recPath.startsWith(examplesPath)) {
                    String modePrefix = mode.getTitle() + " ";
                    if (mode.getTitle().equals("Standard")) {
                        // "Standard examples" is dorky
                        modePrefix = "";
                    }
                    purtyPath = modePrefix + "examples → " + recPath.substring(examplesPath.length() + 1);
                    break;
                }
                if (mode.coreLibraries != null) {
                    for (Library lib : mode.coreLibraries) {
                        examplesFolder = lib.getExamplesFolder();
                        examplesPath = examplesFolder.getAbsolutePath();
                        if (recPath.startsWith(examplesPath)) {
                            purtyPath = lib.getName() + " examples → " + recPath.substring(examplesPath.length() + 1);
                            break;
                        }
                    }
                }
                if (mode.contribLibraries != null) {
                    for (Library lib : mode.contribLibraries) {
                        examplesFolder = lib.getExamplesFolder();
                        examplesPath = examplesFolder.getAbsolutePath();
                        if (recPath.startsWith(examplesPath)) {
                            purtyPath = lib.getName() + " examples → " + recPath.substring(examplesPath.length() + 1);
                            break;
                        }
                    }
                }
            }
        }
        if (purtyPath == null) {
            String homePath = System.getProperty("user.home");
            if (recPath.startsWith(homePath)) {
                // Not localized, but this is gravy. It'll work on OS X & EN Windows
                String desktopPath = homePath + File.separator + "Desktop";
                if (recPath.startsWith(desktopPath)) {
                    purtyPath = "Desktop → " + recPath.substring(desktopPath.length() + 1);
                } else {
                    //purtyPath = "⌂ → " + recPath.substring(homePath.length() + 1);
                    //purtyPath = "Home → " + recPath.substring(homePath.length() + 1);
                    String userName = new File(homePath).getName();
                    //purtyPath = "⌂ " + userName + " → " + recPath.substring(homePath.length() + 1);
                    purtyPath = userName + " → " + recPath.substring(homePath.length() + 1);
                }
            } else {
                purtyPath = recPath;
            }
        }
        //      JMenuItem item = new JMenuItem(rec.getName() + " | " + purtyPath);
        JMenuItem item = new JMenuItem(purtyPath);
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                // Base will call handle() (below) which will cause this entry to
                // be removed from the list and re-added to the end. If already
                // opened, Base will bring the window forward, and also call handle()
                // so that it's re-queued to the newest slot in the Recent menu.
                base.handleOpen(rec.path);
            //          if (rec.sketch == null) {
            //            // this will later call 'add' to put it back on the stack
            //            base.handleOpen(rec.path); //, rec.state);
            ////            int index = findRecord(rec);
            ////            if (index != -1) {
            ////              records.remove(index);  // remove from the list
            ////              save();  // write the recent file with the latest
            ////            }
            //          } else {
            ////              System.out.println("sketch not null in handleOpen: " + record.getPath());
            //          }
            }
        });
        //menu.add(item);
        menu.insert(item, 0);
    } catch (Exception e) {
        // Strange things can happen... report them for the geeky and move on:
        // https://github.com/processing/processing/issues/2463
        e.printStackTrace();
    }
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Mode(processing.app.Mode) Library(processing.app.Library) JMenuItem(javax.swing.JMenuItem) File(java.io.File) IOException(java.io.IOException)

Example 84 with ActionListener

use of java.awt.event.ActionListener in project checkstyle by checkstyle.

the class OperatorHelper method myMethod.

//indent:4 exp:4
private void myMethod() {
    //indent:4 exp:4
    class localFoo {
    }
    class localFoo2 {

        //indent:12 exp:12
        int x;

        //indent:12 exp:12
        int func() {
            return 3;
        }
    }
    //indent:8 exp:8
    //     : this is broken right now: //indent:8 exp:8
    //   1) this is both an expression and an OBJBLOCK //indent:8 exp:8
    //   2) methods aren't yet parsed //indent:8 exp:8
    //   3) only CLASSDEF is handled now, not OBJBLOCK //indent:8 exp:8
    new JButton().addActionListener(new //indent:8 exp:8
    ActionListener() {

        //indent:8 exp:8
        public void actionPerformed(ActionEvent e) {
        //indent:12 exp:12
        }
    });
    //indent:8 exp:8
    new JButton().addActionListener(new //indent:8 exp:8
    ActionListener() {

        public void actionPerformed(ActionEvent e) {
            //indent:12 exp:12
            //indent:16 exp:16
            int i = 2;
        }
    });
    //indent:8 exp:8
    Object o = new //indent:8 exp:8
    ActionListener() {

        //indent:8 exp:8
        public void actionPerformed(ActionEvent e) {
        //indent:12 exp:12
        }
    };
    //indent:8 exp:8
    myfunc2(//indent:8 exp:8
    10, //indent:8 exp:8
    10, //indent:8 exp:8
    10, myfunc3(//indent:12 exp:>=12
    11, //indent:12 exp:>=12
    11, 11, //indent:16 exp:>=16
    11), //indent:12 exp:>=12
    10, //indent:12 exp:>=12
    10, //indent:12 exp:>=12
    10);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton)

Example 85 with ActionListener

use of java.awt.event.ActionListener in project enumerable by hraberg.

the class LambdaTest method createSingleMethodInterfaceTakingOneArgumentUsingGenericDelegate.

@Test
public void createSingleMethodInterfaceTakingOneArgumentUsingGenericDelegate() throws Exception {
    ActionEvent actual;
    ActionListener a = delegate(e, actual = e);
    ActionEvent event = new ActionEvent(this, 1, "command");
    a.actionPerformed(event);
    assertSame(event, actual);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Test(org.junit.Test)

Aggregations

ActionListener (java.awt.event.ActionListener)1347 ActionEvent (java.awt.event.ActionEvent)1303 JButton (javax.swing.JButton)363 JPanel (javax.swing.JPanel)345 JLabel (javax.swing.JLabel)234 JMenuItem (javax.swing.JMenuItem)191 BoxLayout (javax.swing.BoxLayout)150 GridBagConstraints (java.awt.GridBagConstraints)121 Insets (java.awt.Insets)121 GridBagLayout (java.awt.GridBagLayout)114 Dimension (java.awt.Dimension)113 FlowLayout (java.awt.FlowLayout)110 JCheckBox (javax.swing.JCheckBox)103 JScrollPane (javax.swing.JScrollPane)103 JMenu (javax.swing.JMenu)96 BorderLayout (java.awt.BorderLayout)88 JTextField (javax.swing.JTextField)79 JComboBox (javax.swing.JComboBox)73 ButtonGroup (javax.swing.ButtonGroup)64 ArrayList (java.util.ArrayList)60