Example usage for javax.swing JPopupMenu setDefaultLightWeightPopupEnabled

List of usage examples for javax.swing JPopupMenu setDefaultLightWeightPopupEnabled

Introduction

In this page you can find the example usage for javax.swing JPopupMenu setDefaultLightWeightPopupEnabled.

Prototype

public static void setDefaultLightWeightPopupEnabled(boolean aFlag) 

Source Link

Document

Sets the default value of the lightWeightPopupEnabled property.

Usage

From source file:com.eviware.soapui.SoapUI.java

public static SoapUI startSoapUI(String[] args, String title, String splashImage, SwingSoapUICore core)
        throws Exception {
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "SoapUI");

    frame = new JFrame(title);

    SoapUISplash splash = new SoapUISplash(splashImage, frame);

    frame.setIconImage(UISupport.createImageIcon(FRAME_ICON).getImage());

    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);

    isStandalone = true;/*  w  ww  . j  a  v a2s.co m*/
    soapUICore = core;

    SoapUI soapUI = new SoapUI();
    Workspace workspace = null;

    org.apache.commons.cli.Options options = initSoapUIOptions();
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);

    if (!processCommandLineArgs(cmd, options)) {
        System.exit(1);
    }

    if (workspaceName != null) {
        workspace = WorkspaceFactory.getInstance().openWorkspace(workspaceName, projectOptions);
        soapUICore.getSettings().setString(CURRENT_SOAPUI_WORKSPACE, workspaceName);
    } else {
        String wsfile = soapUICore.getSettings().getString(CURRENT_SOAPUI_WORKSPACE,
                System.getProperty("user.home") + File.separatorChar + DEFAULT_WORKSPACE_FILE);
        try {
            workspace = WorkspaceFactory.getInstance().openWorkspace(wsfile, projectOptions);
        } catch (Exception e) {
            UISupport.setDialogs(new SwingDialogs(null));
            if (UISupport.confirm("Failed to open workspace: [" + e.toString() + "], create new one instead?",
                    "Error")) {
                new File(wsfile).renameTo(new File(wsfile + ".bak"));
                workspace = WorkspaceFactory.getInstance().openWorkspace(wsfile, projectOptions);
            } else {
                System.exit(1);
            }
        }
    }

    core.prepareUI();
    soapUI.show(workspace);
    core.afterStartup(workspace);
    Thread.sleep(500);
    splash.setVisible(false);

    if (getSettings().getBoolean(UISettings.SHOW_STARTUP_PAGE) && !SoapUI.isJXBrowserDisabled(true)) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                showPushPage();
            }
        });
    }

    frame.setSize(1000, 750);

    String[] args2 = cmd.getArgs();
    if (args2 != null && args2.length > 0) {
        String arg = args2[0];
        if (arg.toUpperCase().endsWith(".WSDL") || arg.toUpperCase().endsWith(".WADL")) {
            SwingUtilities.invokeLater(new WsdlProjectCreator(arg));
        } else {
            try {
                URL url = new URL(arg);
                SwingUtilities.invokeLater(new RestProjectCreator(url));
            } catch (Exception e) {
            }
        }
    }
    return soapUI;
}

From source file:ffx.ui.MainPanel.java

/**
 * <p>//  w  ww. ja  v  a  2 s. c  o m
 * initialize</p>
 */
public void initialize() {
    if (init) {
        return;
    }
    init = true;
    String dir = System.getProperty("user.dir",
            FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath());
    setCWD(new File(dir));
    locale = new FFXLocale("en", "US");
    JDialog splashScreen = null;
    ClassLoader loader = getClass().getClassLoader();
    if (!GraphicsEnvironment.isHeadless()) {
        // Splash Screen
        JFrame.setDefaultLookAndFeelDecorated(true);
        splashScreen = new JDialog(frame, false);
        ImageIcon logo = new ImageIcon(loader.getResource("ffx/ui/icons/splash.png"));
        JLabel ffxLabel = new JLabel(logo);
        ffxLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
        Container contentpane = splashScreen.getContentPane();
        contentpane.setLayout(new BorderLayout());
        contentpane.add(ffxLabel, BorderLayout.CENTER);
        splashScreen.setUndecorated(true);
        splashScreen.pack();
        Dimension screenDimension = getToolkit().getScreenSize();
        Dimension splashDimension = splashScreen.getSize();
        splashScreen.setLocation((screenDimension.width - splashDimension.width) / 2,
                (screenDimension.height - splashDimension.height) / 2);
        splashScreen.setResizable(false);
        splashScreen.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        splashScreen.setVisible(true);
        // Make all pop-up Menus Heavyweight so they play nicely with Java3D
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    }
    // Create the Root Node
    dataRoot = new MSRoot();
    Border bb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    statusLabel = new JLabel("  ");
    JLabel stepLabel = new JLabel("  ");
    stepLabel.setHorizontalAlignment(JLabel.RIGHT);
    JLabel energyLabel = new JLabel("  ");
    energyLabel.setHorizontalAlignment(JLabel.RIGHT);
    JPanel statusPanel = new JPanel(new GridLayout(1, 3));
    statusPanel.setBorder(bb);
    statusPanel.add(statusLabel);
    statusPanel.add(stepLabel);
    statusPanel.add(energyLabel);
    if (!GraphicsEnvironment.isHeadless()) {
        GraphicsConfigTemplate3D template3D = new GraphicsConfigTemplate3D();
        template3D.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED);
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getBestConfiguration(template3D);
        graphicsCanvas = new GraphicsCanvas(gc, this);
        graphicsPanel = new GraphicsPanel(graphicsCanvas, statusPanel);
    }
    // Initialize various Panels
    hierarchy = new Hierarchy(this);
    hierarchy.setStatus(statusLabel, stepLabel, energyLabel);
    keywordPanel = new KeywordPanel(this);
    modelingPanel = new ModelingPanel(this);
    JPanel treePane = new JPanel(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(hierarchy, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    treePane.add(scrollPane, BorderLayout.CENTER);
    tabbedPane = new JTabbedPane();

    ImageIcon graphicsIcon = new ImageIcon(loader.getResource("ffx/ui/icons/monitor.png"));
    ImageIcon keywordIcon = new ImageIcon(loader.getResource("ffx/ui/icons/key.png"));
    ImageIcon modelingIcon = new ImageIcon(loader.getResource("ffx/ui/icons/cog.png"));
    tabbedPane.addTab(locale.getValue("Graphics"), graphicsIcon, graphicsPanel);
    tabbedPane.addTab(locale.getValue("KeywordEditor"), keywordIcon, keywordPanel);
    tabbedPane.addTab(locale.getValue("ModelingCommands"), modelingIcon, modelingPanel);
    tabbedPane.addChangeListener(this);
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, tabbedPane);

    /* splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false,
     treePane, graphicsPanel); */
    splitPane.setResizeWeight(0.25);
    splitPane.setOneTouchExpandable(true);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    if (!GraphicsEnvironment.isHeadless()) {
        mainMenu = new MainMenu(this);
        add(mainMenu.getToolBar(), BorderLayout.NORTH);
        getModelingShell();
        loadPrefs();
        SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this));
        splashScreen.dispose();
    }
}

From source file:org.columba.core.main.Bootstrap.java

public void run(String args[]) throws Exception {

    addNativeJarsToClasspath();/*from  www. ja v a2 s .  co m*/
    setLibraryPath();

    // For the Mac ScreenBarMenus to work, this must be declared before
    // *ANY* AWT / Swing gets initialised. Do *NOT* move it to plugin init
    // location because that is too late...
    if (OSInfo.isMac()) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Columba");
    }

    Logging.createDefaultHandler();
    registerCommandLineArguments();

    StackProfiler profiler = new StackProfiler();
    profiler.push("main");
    profiler.push("config");
    profiler.push("profile");
    // prompt user for profile
    Profile profile = ProfileManager.getInstance().getProfile(path);
    profiler.pop("profile");

    // initialize configuration with selected profile
    DefaultConfigDirectory.getInstance().setCurrentPath(profile.getLocation());
    new Config(profile.getLocation());
    profiler.pop("config");

    // if user doesn't overwrite logger settings with commandline arguments
    // just initialize default logging
    // Logging.createDefaultHandler();
    Logging.createDefaultFileHandler(DefaultConfigDirectory.getDefaultPath());

    for (int i = 0; i < args.length; i++) {
        LOG.info("arg[" + i + "]=" + args[i]);
    }

    SessionController.passToRunningSessionAndExit(args);

    // enable debugging of repaint manager to track down swing gui
    // access from outside the awt-event dispatcher thread

    if (Logging.DEBUG)
        RepaintManager.setCurrentManager(new DebugRepaintManager());

    // use heavy-weight popups to ensure they are always on top
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    // keep track of active windows (used by dialogs which don't have a
    // direct parent)
    ActiveWindowTracker.class.getClass();

    // show splash screen
    StartUpFrame frame = null;
    if (showSplashScreen) {
        frame = new StartUpFrame();
        frame.setVisible(true);
    }

    // register protocol handler
    System.setProperty("java.protocol.handler.pkgs",
            "org.columba.core.url|" + System.getProperty("java.protocol.handler.pkgs", ""));

    profiler.push("i18n");
    // load user-customised language pack
    GlobalResourceLoader.loadLanguage();
    profiler.pop("i18n");

    SaveConfig task = new SaveConfig();
    BackgroundTaskManager.getInstance().register(task);
    ShutdownManager.getInstance().register(task);

    profiler.push("plugins core");
    initPlugins();
    profiler.pop("plugins core");

    profiler.push("components");
    // init all components
    ComponentManager.getInstance().init();
    ComponentManager.getInstance().registerCommandLineArguments();
    profiler.pop("components");

    // set Look & Feel
    ThemeSwitcher.setTheme();

    // initialize platform-dependant services
    initPlatformServices();

    // init font configuration
    new FontProperties();

    // set application wide font
    FontProperties.setFont();

    //       handle commandline parameters
    if (handleCoreCommandLineParameters(args)) {
        System.exit(0);
    }

    // handle the commandline arguments of the modules
    ComponentManager.getInstance()
            .handleCommandLineParameters(ColumbaCmdLineParser.getInstance().getParsedCommandLine());

    profiler.push("plugins external");
    // now load all available plugins
    // PluginManager.getInstance().initExternalPlugins();
    profiler.pop("plugins external");

    profiler.push("frames");

    // restore frames of last session
    if (ColumbaCmdLineParser.getInstance().getRestoreLastSession()) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                FrameManager.getInstance().openStoredViews();
            }
        });
    }

    /* initialize services before dismissing the splash screen */
    ServiceManager.getInstance().initServices();

    // register shutdown manager
    ShutdownManager.getInstance().register(new Runnable() {
        public void run() {

            ServiceManager.getInstance().stopServices();
            ServiceManager.getInstance().disposeServices();
        }
    });

    profiler.pop("frames");

    // Add the tray icon to the System tray
    // ColumbaTrayIcon.getInstance().addToSystemTray(
    // FrameManager.getInstance().getActiveFrameMediator()
    // .getFrameMediator());

    profiler.push("tagging");

    // initialize tagging
    if (ENABLE_TAGS) {
        AssociationStore.getInstance().init();
        // register for cleanup
        ShutdownManager.getInstance().register(AssociationStore.getInstance());
    }

    profiler.pop("tagging");

    // hide splash screen
    if (frame != null) {
        frame.setVisible(false);
    }

    // call the postStartups of the modules
    // e.g. check for default mailclient
    ComponentManager.getInstance().postStartup();

    /* everything is up and running, start services */
    ServiceManager.getInstance().startServices();

    profiler.pop("main");

}

From source file:org.ngrinder.recorder.Recorder.java

private static void initEnvironment() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        throw new NGrinderRuntimeException("nGrinder Recorder can not run in the headless environment");
    }// ww w .j av a 2  s.  c o m
    System.setProperty("com.apple.eawt.CocoaComponent.CompatibilityMode", "false");
    System.setProperty("apple.laf.useScreenMenuBar", "false");
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "nGrinder Recorder");
    System.setProperty("python.cachedir.skip", "true");
    System.setProperty("jxbrowser.ie.compatibility-disabled", "true");
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    UIManager.setLookAndFeel(getLookAndFeelClassName());
    // Make the jython is loaded in the background
    AsyncUtil.invokeAsync(new Runnable() {
        @Override
        public void run() {
            org.python.core.ParserFacade.parse("print 'hello'", CompileMode.exec, "unnamed",
                    new CompilerFlags(CompilerFlags.PyCF_DONT_IMPLY_DEDENT | CompilerFlags.PyCF_ONLY_AST));
        }

    });
}

From source file:processing.app.Base.java

public Base(String[] args) throws Exception {
    Thread deleteFilesOnShutdownThread = new Thread(DeleteFilesOnShutdown.INSTANCE);
    deleteFilesOnShutdownThread.setName("DeleteFilesOnShutdown");
    Runtime.getRuntime().addShutdownHook(deleteFilesOnShutdownThread);

    BaseNoGui.initLogger();//  ww  w. j a va  2  s . c o  m

    initLogger();

    BaseNoGui.initPlatform();

    BaseNoGui.getPlatform().init();

    BaseNoGui.initPortableFolder();

    // Look for a possible "--preferences-file" parameter and load preferences
    BaseNoGui.initParameters(args);

    CommandlineParser parser = new CommandlineParser(args);
    parser.parseArgumentsPhase1();
    commandLine = !parser.isGuiMode();

    BaseNoGui.checkInstallationFolder();

    // If no path is set, get the default sketchbook folder for this platform
    if (BaseNoGui.getSketchbookPath() == null) {
        File defaultFolder = getDefaultSketchbookFolderOrPromptForIt();
        if (BaseNoGui.getPortableFolder() != null)
            PreferencesData.set("sketchbook.path", BaseNoGui.getPortableSketchbookFolder());
        else
            PreferencesData.set("sketchbook.path", defaultFolder.getAbsolutePath());
        if (!defaultFolder.exists()) {
            defaultFolder.mkdirs();
        }
    }

    SplashScreenHelper splash;
    if (parser.isGuiMode()) {
        // Setup all notification widgets
        splash = new SplashScreenHelper(SplashScreen.getSplashScreen());
        BaseNoGui.notifier = new GUIUserNotifier(this);

        // Setup the theme coloring fun
        Theme.init();
        System.setProperty("swing.aatext", PreferencesData.get("editor.antialias", "true"));

        // Set the look and feel before opening the window
        try {
            BaseNoGui.getPlatform().setLookAndFeel();
        } catch (Exception e) {
            // ignore
        }

        // Use native popups so they don't look so crappy on osx
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    } else {
        splash = new SplashScreenHelper(null);
    }

    splash.splashText(tr("Loading configuration..."));

    BaseNoGui.initVersion();

    // Don't put anything above this line that might make GUI,
    // because the platform has to be inited properly first.

    // Create a location for untitled sketches
    untitledFolder = FileUtils.createTempFolder("untitled" + new Random().nextInt(Integer.MAX_VALUE), ".tmp");
    DeleteFilesOnShutdown.add(untitledFolder);

    splash.splashText(tr("Initializing packages..."));
    BaseNoGui.initPackages();

    splash.splashText(tr("Preparing boards..."));

    if (!isCommandLine()) {
        rebuildBoardsMenu();
        rebuildProgrammerMenu();
    } else {
        TargetBoard lastSelectedBoard = BaseNoGui.getTargetBoard();
        if (lastSelectedBoard != null)
            BaseNoGui.selectBoard(lastSelectedBoard);
    }

    // Setup board-dependent variables.
    onBoardOrPortChange();

    pdeKeywords = new PdeKeywords();
    pdeKeywords.reload();

    contributionInstaller = new ContributionInstaller(BaseNoGui.getPlatform(),
            new GPGDetachedSignatureVerifier());
    libraryInstaller = new LibraryInstaller(BaseNoGui.getPlatform());

    parser.parseArgumentsPhase2();

    // Save the preferences. For GUI mode, this happens in the quit
    // handler, but for other modes we should also make sure to save
    // them.
    if (parser.isForceSavePrefs()) {
        PreferencesData.save();
    }

    if (parser.isInstallBoard()) {
        ContributionsIndexer indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder(),
                BaseNoGui.getHardwareFolder(), BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier());
        ProgressListener progressListener = new ConsoleProgressListener();

        List<String> downloadedPackageIndexFiles = contributionInstaller.updateIndex(progressListener);
        contributionInstaller.deleteUnknownFiles(downloadedPackageIndexFiles);
        indexer.parseIndex();
        indexer.syncWithFilesystem();

        String[] boardToInstallParts = parser.getBoardToInstall().split(":");

        ContributedPlatform selected = null;
        if (boardToInstallParts.length == 3) {
            selected = indexer.getIndex().findPlatform(boardToInstallParts[0], boardToInstallParts[1],
                    VersionHelper.valueOf(boardToInstallParts[2]).toString());
        } else if (boardToInstallParts.length == 2) {
            List<ContributedPlatform> platformsByName = indexer.getIndex().findPlatforms(boardToInstallParts[0],
                    boardToInstallParts[1]);
            Collections.sort(platformsByName, new DownloadableContributionVersionComparator());
            if (!platformsByName.isEmpty()) {
                selected = platformsByName.get(platformsByName.size() - 1);
            }
        }
        if (selected == null) {
            System.out.println(tr("Selected board is not available"));
            System.exit(1);
        }

        ContributedPlatform installed = indexer.getInstalled(boardToInstallParts[0], boardToInstallParts[1]);

        if (!selected.isBuiltIn()) {
            contributionInstaller.install(selected, progressListener);
        }

        if (installed != null && !installed.isBuiltIn()) {
            contributionInstaller.remove(installed);
        }

        System.exit(0);

    } else if (parser.isInstallLibrary()) {
        BaseNoGui.onBoardOrPortChange();

        ProgressListener progressListener = new ConsoleProgressListener();
        libraryInstaller.updateIndex(progressListener);

        LibrariesIndexer indexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder());
        indexer.parseIndex();
        indexer.setLibrariesFolders(BaseNoGui.getLibrariesFolders());
        indexer.rescanLibraries();

        for (String library : parser.getLibraryToInstall().split(",")) {
            String[] libraryToInstallParts = library.split(":");

            ContributedLibrary selected = null;
            if (libraryToInstallParts.length == 2) {
                selected = indexer.getIndex().find(libraryToInstallParts[0],
                        VersionHelper.valueOf(libraryToInstallParts[1]).toString());
            } else if (libraryToInstallParts.length == 1) {
                List<ContributedLibrary> librariesByName = indexer.getIndex().find(libraryToInstallParts[0]);
                Collections.sort(librariesByName, new DownloadableContributionVersionComparator());
                if (!librariesByName.isEmpty()) {
                    selected = librariesByName.get(librariesByName.size() - 1);
                }
            }
            if (selected == null) {
                System.out.println(tr("Selected library is not available"));
                System.exit(1);
            }

            Optional<ContributedLibrary> mayInstalled = indexer.getIndex()
                    .getInstalled(libraryToInstallParts[0]);
            if (mayInstalled.isPresent() && selected.isIDEBuiltIn()) {
                System.out.println(tr(I18n.format(
                        "Library {0} is available as built-in in the IDE.\nRemoving the other version {1} installed in the sketchbook...",
                        library, mayInstalled.get().getParsedVersion())));
                libraryInstaller.remove(mayInstalled.get(), progressListener);
            } else {
                libraryInstaller.install(selected, mayInstalled, progressListener);
            }
        }

        System.exit(0);

    } else if (parser.isVerifyOrUploadMode()) {
        // Set verbosity for command line build
        PreferencesData.setBoolean("build.verbose", parser.isDoVerboseBuild());
        PreferencesData.setBoolean("upload.verbose", parser.isDoVerboseUpload());

        // Set preserve-temp flag
        PreferencesData.setBoolean("runtime.preserve.temp.files", parser.isPreserveTempFiles());

        // Make sure these verbosity preferences are only for the current session
        PreferencesData.setDoSave(false);

        Sketch sketch = null;
        String outputFile = null;

        try {
            // Build
            splash.splashText(tr("Verifying..."));

            File sketchFile = BaseNoGui.absoluteFile(parser.getFilenames().get(0));
            sketch = new Sketch(sketchFile);

            outputFile = new Compiler(sketch).build(progress -> {
            }, false);
        } catch (Exception e) {
            // Error during build
            e.printStackTrace();
            System.exit(1);
        }

        if (parser.isUploadMode()) {
            // Upload
            splash.splashText(tr("Uploading..."));

            try {
                List<String> warnings = new ArrayList<>();
                UploaderUtils uploader = new UploaderUtils();
                boolean res = uploader.upload(sketch, null, outputFile, parser.isDoUseProgrammer(),
                        parser.isNoUploadPort(), warnings);
                for (String warning : warnings) {
                    System.out.println(tr("Warning") + ": " + warning);
                }
                if (!res) {
                    throw new Exception();
                }
            } catch (Exception e) {
                // Error during upload
                System.out.flush();
                System.err.flush();
                System.err.println(tr("An error occurred while uploading the sketch"));
                System.exit(1);
            }
        }

        // No errors exit gracefully
        System.exit(0);
    } else if (parser.isGuiMode()) {
        splash.splashText(tr("Starting..."));

        for (String path : parser.getFilenames()) {
            // Correctly resolve relative paths
            File file = absoluteFile(path);

            // Fix a problem with systems that use a non-ASCII languages. Paths are
            // being passed in with 8.3 syntax, which makes the sketch loader code
            // unhappy, since the sketch folder naming doesn't match up correctly.
            // http://dev.processing.org/bugs/show_bug.cgi?id=1089
            if (OSUtils.isWindows()) {
                try {
                    file = file.getCanonicalFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            if (!parser.isForceSavePrefs())
                PreferencesData.setDoSave(true);
            if (handleOpen(file, retrieveSketchLocation(".default"), false) == null) {
                String mess = I18n.format(tr("Failed to open sketch: \"{0}\""), path);
                // Open failure is fatal in upload/verify mode
                if (parser.isVerifyOrUploadMode())
                    showError(null, mess, 2);
                else
                    showWarning(null, mess, null);
            }
        }

        installKeyboardInputMap();

        // Check if there were previously opened sketches to be restored
        restoreSketches();

        // Create a new empty window (will be replaced with any files to be opened)
        if (editors.isEmpty()) {
            handleNew();
        }

        new Thread(new BuiltInCoreIsNewerCheck(this)).start();

        // Check for boards which need an additional core
        new Thread(new NewBoardListener(this)).start();

        // Check for updates
        if (PreferencesData.getBoolean("update.check")) {
            new UpdateCheck(this);

            contributionsSelfCheck = new ContributionsSelfCheck(this,
                    new UpdatableBoardsLibsFakeURLsHandler(this), contributionInstaller, libraryInstaller);
            new Timer(false).schedule(contributionsSelfCheck,
                    Constants.BOARDS_LIBS_UPDATABLE_CHECK_START_PERIOD);
        }

    } else if (parser.isNoOpMode()) {
        // Do nothing (intended for only changing preferences)
        System.exit(0);
    } else if (parser.isGetPrefMode()) {
        BaseNoGui.dumpPrefs(parser);
    } else if (parser.isVersionMode()) {
        System.out.println("Arduino: " + BaseNoGui.VERSION_NAME_LONG);
        System.exit(0);
    }
}

From source file:Samples.Advanced.GraphEditorDemo.java

/**
 * a driver for this demo/*from   w w  w.ja v a2  s .  co m*/
 */
@SuppressWarnings("serial")
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final GraphEditorDemo demo = new GraphEditorDemo();

    JMenu menu = new JMenu("File");
    menu.add(new AbstractAction("Make Image") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showSaveDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                demo.writeJPEGImage(file);
            }
        }
    });
    menu.add(new AbstractAction("Print") {
        public void actionPerformed(ActionEvent e) {
            PrinterJob printJob = PrinterJob.getPrinterJob();
            printJob.setPrintable(demo);
            if (printJob.printDialog()) {
                try {
                    printJob.print();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    JMenu matrixMenu = new JMenu();
    matrixMenu.setText("Matrix");
    matrixMenu.setIcon(null);
    matrixMenu.setPreferredSize(new Dimension(80, 20));
    menuBar.add(matrixMenu);
    JMenuItem copyMatrix = new JMenuItem("Copy Matrix to clipboard", KeyEvent.VK_C);
    copyMatrix.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
    menuBar.add(copyMatrix);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(demo);
    copyMatrix.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Vem textTransfer = new Vem();

            //Set up Matrix
            List<Integer[]> graphMatrix = new ArrayList<Integer[]>();
            int MatrixSize = graph.getVertexCount();

            Integer[] activeV = new Integer[MatrixSize];
            int count = 0;
            int activeVPos = 0;

            while (activeVPos < MatrixSize) {
                if (graph.containsVertex(count)) {
                    activeV[activeVPos] = count;
                    activeVPos++;
                }
                count++;
            }

            // sgv.g.getVertices().toArray()  ((Integer[])(sgv.g.getVertices().toArray()))
            for (int i = 0; i < MatrixSize; i++) {
                Integer[] tempArray = new Integer[MatrixSize];
                for (int j = 0; j < MatrixSize; j++) {
                    if (graph.findEdge(activeV[i], activeV[j]) != null) {
                        tempArray[j] = 1;
                    } else {
                        tempArray[j] = 0;
                    }
                }
                graphMatrix.add(tempArray);
            }
            //graphMatrix.add(new Integer[]{1, 2, 3});
            //graphMatrix.add(new Integer[]{4, 5 , 6, 7});

            //System.out.println(matrixToString(graphMatrix));
            //System.out.println(matrixToMathematica(graphMatrix));

            textTransfer.setClipboardContents("" + matrixToMathematica(graphMatrix));
            System.out.println("Clipboard contains:" + textTransfer.getClipboardContents());
        }
    });

    frame.pack();
    frame.setVisible(true);
}

From source file:Samples.Advanced.GraphEditorDemo2.java

/**
 * a driver for this demo/*from  www . j  av  a2 s .c  o m*/
 */
@SuppressWarnings("serial")
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final GraphEditorDemo2 demo = new GraphEditorDemo2();

    JMenu menu = new JMenu("File");
    menu.add(new AbstractAction("Make Image") {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            int option = chooser.showSaveDialog(demo);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                demo.writeJPEGImage(file);
            }
        }
    });
    menu.add(new AbstractAction("Print") {
        public void actionPerformed(ActionEvent e) {
            PrinterJob printJob = PrinterJob.getPrinterJob();
            printJob.setPrintable(demo);
            if (printJob.printDialog()) {
                try {
                    printJob.print();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(demo);
    frame.pack();
    frame.setVisible(true);
}