/* We look for System property sun.jvm.hotspot.jdi.<vm version>. * This property should have the value of JDK HOME directory for * the given <vm version>. */ private static String getSAClassPathForVM(String vmVersion) { final String prefix = "sun.jvm.hotspot.jdi."; // look for exact match of VM version String jvmHome = System.getProperty(prefix + vmVersion); if (DEBUG) { System.out.println("looking for System property " + prefix + vmVersion); } if (jvmHome == null) { // omit chars after first '-' in VM version and try // for example, in '1.5.0-b55' we take '1.5.0' int index = vmVersion.indexOf('-'); if (index != -1) { vmVersion = vmVersion.substring(0, index); if (DEBUG) { System.out.println("looking for System property " + prefix + vmVersion); } jvmHome = System.getProperty(prefix + vmVersion); } if (jvmHome == null) { // System property is not set if (DEBUG) { System.out.println("can't locate JDK home for " + vmVersion); } return null; } } if (DEBUG) { System.out.println("JDK home for " + vmVersion + " is " + jvmHome); } // sa-jdi is in $JDK_HOME/lib directory StringBuffer buf = new StringBuffer(); buf.append(jvmHome); buf.append(File.separatorChar); buf.append("lib"); buf.append(File.separatorChar); buf.append("sa-jdi.jar"); return buf.toString(); }
/** * Returns the main control panel. * * @param mainFrame The main test frame. * @param mainTabbedPane The main tabbed pane. * @param mainTabPreviewPainter The preview painter of the main tabbed pane. * @param toolbar The toolbar of the main test frame. * @return The main control panel. */ public static JPanel getMainControlPanel( final JFrame mainFrame, final JTabbedPane mainTabbedPane, final MyMainTabPreviewPainter mainTabPreviewPainter, final JToolBar toolbar) { FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm); // builder.setDefaultDialogBorder(); builder.appendSeparator("Title pane settings"); final JCheckBox markAsModified = new JCheckBox("Marked modified"); markAsModified.setOpaque(false); markAsModified.setSelected(false); markAsModified.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mainFrame .getRootPane() .putClientProperty( SubstanceLookAndFeel.WINDOW_MODIFIED, (markAsModified.isSelected() ? Boolean.TRUE : false)); } }); builder.append("Modified", markAsModified); final JCheckBox heapPanel = new JCheckBox("Has heap panel"); heapPanel.setOpaque(false); heapPanel.setSelected(false); heapPanel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SubstanceLookAndFeel.setWidgetVisible( mainFrame.getRootPane(), heapPanel.isSelected(), SubstanceWidgetType.TITLE_PANE_HEAP_STATUS); } }); builder.append("Heap panel", heapPanel); JButton changeTitleButton = new JButton("Change"); changeTitleButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String random = "abcdefghijklmnopqrstuvwxyz "; int length = 60 + (int) (150 * Math.random()); String title = ""; while (length > 0) { title += random.charAt((int) (random.length() * Math.random())); length--; } mainFrame.setTitle(title); } }); builder.append("Title string", changeTitleButton); builder.appendSeparator("Miscellaneous"); final JCheckBox defaultRoundedCorners = new JCheckBox("by default"); defaultRoundedCorners.setOpaque(false); boolean roundable = Boolean.valueOf( System.getProperty(SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS_PROPERTY, "True")); defaultRoundedCorners.setSelected(roundable); defaultRoundedCorners.setEnabled(roundable); defaultRoundedCorners.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { UIManager.put( SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS, defaultRoundedCorners.isSelected()); } }); builder.append("Rounded Windows", defaultRoundedCorners); final JCheckBox useThemedDefaultIconsCheckBox = new JCheckBox("use themed icons"); useThemedDefaultIconsCheckBox.setOpaque(false); useThemedDefaultIconsCheckBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { UIManager.put( SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, useThemedDefaultIconsCheckBox.isSelected() ? Boolean.TRUE : null); mainFrame.repaint(); } }); } }); builder.append("Themed icons", useThemedDefaultIconsCheckBox); final JCheckBox useConstantThemesOnDialogs = new JCheckBox("use constant themes"); useConstantThemesOnDialogs.setOpaque(false); useConstantThemesOnDialogs.setSelected(SubstanceLookAndFeel.isToUseConstantThemesOnDialogs()); useConstantThemesOnDialogs.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { SubstanceLookAndFeel.setToUseConstantThemesOnDialogs( useConstantThemesOnDialogs.isSelected()); SubstanceLookAndFeel.setSkin( SubstanceLookAndFeel.getCurrentSkin(mainFrame.getRootPane())); } }); } }); builder.append("Option pane icons", useConstantThemesOnDialogs); final JComboBox placementCombo = new JComboBox(new Object[] {"top", "bottom", "left", "right"}); placementCombo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String selected = (String) placementCombo.getSelectedItem(); if ("top".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.TOP); if ("bottom".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.BOTTOM); if ("left".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.LEFT); if ("right".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.RIGHT); } }); builder.append("Placement", placementCombo); try { final JComboBox overviewKindCombo = new FlexiComboBox<TabOverviewKind>( TabOverviewKind.GRID, TabOverviewKind.MENU_CAROUSEL, TabOverviewKind.ROUND_CAROUSEL) { @Override public String getCaption(TabOverviewKind item) { return item.getName(); } }; overviewKindCombo.setSelectedItem( LafWidgetUtilities2.getTabPreviewPainter(mainTabbedPane).getOverviewKind(mainTabbedPane)); overviewKindCombo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mainTabPreviewPainter.setTabOverviewKind( (TabOverviewKind) overviewKindCombo.getSelectedItem()); } }); builder.append("Overview kind", overviewKindCombo); } catch (NoClassDefFoundError ignored) { } final JComboBox menuGutterFillCombo = new FlexiComboBox<MenuGutterFillKind>( MenuGutterFillKind.NONE, MenuGutterFillKind.SOFT, MenuGutterFillKind.HARD, MenuGutterFillKind.SOFT_FILL, MenuGutterFillKind.HARD_FILL) { @Override public String getCaption(MenuGutterFillKind item) { return item.name(); } }; menuGutterFillCombo.setSelectedItem(MenuGutterFillKind.HARD); menuGutterFillCombo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { UIManager.put( SubstanceLookAndFeel.MENU_GUTTER_FILL_KIND, menuGutterFillCombo.getSelectedItem()); } }); builder.append("Menu fill", menuGutterFillCombo); final JComboBox focusKindCombo = new FlexiComboBox<FocusKind>(FocusKind.values()) { @Override public String getCaption(FocusKind item) { return item.name(); } }; focusKindCombo.setSelectedItem(FocusKind.ALL_INNER); focusKindCombo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, focusKindCombo.getSelectedItem()); } }); builder.append("Focus kind", focusKindCombo); JButton buttonGlassPane = new JButton("Show"); buttonGlassPane.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JPanel glassPane = new JPanel() { @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D graphics = (Graphics2D) g; int height = getHeight(); int width = getWidth(); Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 0.4); graphics.setComposite(c); for (int i = 0; i < height; i++) { Color color = (i % 2 == 0) ? new Color(200, 200, 255) : new Color(230, 230, 255); graphics.setColor(color); graphics.drawLine(0, i, width, i); } Composite c2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 1.0); graphics.setComposite(c2); } }; glassPane.setOpaque(false); glassPane.addMouseListener(new MouseAdapter() {}); glassPane.addKeyListener(new KeyAdapter() {}); mainFrame.setGlassPane(glassPane); new Thread() { @Override public void run() { glassPane.setVisible(true); try { Thread.sleep(5000); } catch (InterruptedException ie) { ie.printStackTrace(); } glassPane.setVisible(false); } }.start(); } }); builder.append("Glass pane", buttonGlassPane); builder.appendSeparator("Custom animations"); final JCheckBox allowFocusLoopAnimations = new JCheckBox("Allow animation"); allowFocusLoopAnimations.setOpaque(false); allowFocusLoopAnimations.setSelected( AnimationConfigurationManager.getInstance() .isAnimationAllowed(AnimationFacet.FOCUS_LOOP_ANIMATION, null)); allowFocusLoopAnimations.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (allowFocusLoopAnimations.isSelected()) { AnimationConfigurationManager.getInstance() .allowAnimations(AnimationFacet.FOCUS_LOOP_ANIMATION); } else { AnimationConfigurationManager.getInstance() .disallowAnimations(AnimationFacet.FOCUS_LOOP_ANIMATION); } } }); builder.append("Focus loop", allowFocusLoopAnimations); final JCheckBox allowGlowIconAnimations = new JCheckBox("Allow animation"); allowGlowIconAnimations.setOpaque(false); allowGlowIconAnimations.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (allowGlowIconAnimations.isSelected()) { AnimationConfigurationManager.getInstance().allowAnimations(AnimationFacet.ICON_GLOW); } else { AnimationConfigurationManager.getInstance() .disallowAnimations(AnimationFacet.ICON_GLOW); } } }); builder.append("Icon glow", allowGlowIconAnimations); final JCheckBox allowGhostIconAnimations = new JCheckBox("Allow animation"); allowGhostIconAnimations.setOpaque(false); allowGhostIconAnimations.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (allowGhostIconAnimations.isSelected()) { AnimationConfigurationManager.getInstance() .allowAnimations(AnimationFacet.GHOSTING_ICON_ROLLOVER); } else { AnimationConfigurationManager.getInstance() .disallowAnimations(AnimationFacet.GHOSTING_ICON_ROLLOVER); } } }); builder.append("Icon rollover", allowGhostIconAnimations); final JCheckBox allowGhostPressAnimations = new JCheckBox("Allow animation"); allowGhostPressAnimations.setOpaque(false); allowGhostPressAnimations.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (allowGhostPressAnimations.isSelected()) { AnimationConfigurationManager.getInstance() .allowAnimations(AnimationFacet.GHOSTING_BUTTON_PRESS); } else { AnimationConfigurationManager.getInstance() .disallowAnimations(AnimationFacet.GHOSTING_BUTTON_PRESS); } } }); builder.append("Button press", allowGhostPressAnimations); builder.appendSeparator("Toolbar"); final JCheckBox isToolbarFlat = new JCheckBox("Is flat"); isToolbarFlat.setOpaque(false); isToolbarFlat.setSelected(true); isToolbarFlat.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toolbar.putClientProperty( SubstanceLookAndFeel.FLAT_PROPERTY, isToolbarFlat.isSelected()); toolbar.repaint(); } }); builder.append("Flat", isToolbarFlat); builder.appendSeparator("Menu bar"); final JCheckBox menuSearch = new JCheckBox("Has menu search"); menuSearch.setOpaque(false); menuSearch.setSelected(false); menuSearch.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SubstanceLookAndFeel.setWidgetVisible( mainFrame.getRootPane(), menuSearch.isSelected(), SubstanceWidgetType.MENU_SEARCH); } }); builder.append("Menu search", menuSearch); final JCheckBox menuLocale = new JCheckBox("Has custom locale"); menuLocale.setOpaque(false); menuLocale.setSelected(false); menuLocale.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (menuLocale.isSelected()) { mainFrame.getJMenuBar().setLocale(Locale.FRENCH); mainFrame .getJMenuBar() .putClientProperty(LafWidget.IGNORE_GLOBAL_LOCALE, Boolean.TRUE); } else { mainFrame.getJMenuBar().putClientProperty(LafWidget.IGNORE_GLOBAL_LOCALE, null); } } }); builder.append("Menu locale", menuLocale); JPanel result = builder.getPanel(); result.setName("Main control panel"); return result; }
static { myLoader = ConnectorImpl.class.getClassLoader(); freeVMClasses = new ArrayList(0); DEBUG = System.getProperty("sun.jvm.hotspot.jdi.ConnectorImpl.DEBUG") != null; }