diff --git a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java index 33e79334f6f7..656a9fd28056 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java @@ -227,38 +227,6 @@ public class LoadingDecorator { } } - public static void main(String[] args) { - IconLoader.activate(); - - final JFrame frame = new JFrame(); - frame.getContentPane().setLayout(new BorderLayout()); - - final JPanel content = new JPanel(new BorderLayout()); - - final LoadingDecorator loadingTree = new LoadingDecorator(new JComboBox(), Disposer.newDisposable(), -1); - - content.add(loadingTree.getComponent(), BorderLayout.CENTER); - - final JCheckBox loadingCheckBox = new JCheckBox("Loading"); - loadingCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - if (loadingTree.isLoading()) { - loadingTree.stopLoading(); - } else { - loadingTree.startLoading(false); - } - } - }); - - content.add(loadingCheckBox, BorderLayout.SOUTH); - - - frame.getContentPane().add(content, BorderLayout.CENTER); - - frame.setBounds(300, 300, 300, 300); - frame.show(); - } - private static class MyLayeredPane extends JLayeredPane { @Override public void doLayout() { diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/ShapeTransform.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/ShapeTransform.java index b7f0777d47ba..3838ad50bf18 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/ShapeTransform.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/ShapeTransform.java @@ -343,70 +343,5 @@ public abstract class ShapeTransform { } } - public static void main(String[] args) { - final JFrame frame = new JFrame(); - frame.getContentPane().setLayout(new BorderLayout()); - final JPanel content = new JPanel(new FlowLayout(FlowLayout.CENTER)); - frame.getContentPane().add(content, BorderLayout.CENTER); - - content.add(new Painter("TOP", new Top())); - content.add(new Painter("LEFT", new Left())); - content.add(new Painter("BOTTOM", new Bottom())); - content.add(new Painter("RIGHT", new Right())); - - frame.setBounds(300, 300, 300, 300); - frame.show(); - } - - private static class Painter extends JLabel { - private final ShapeTransform myT; - - private Painter(String text, ShapeTransform transform) { - setText(text); - setFont(getFont().deriveFont(30f)); - setBorder(new EmptyBorder(6, 6, 6, 6)); - myT = transform; - setOpaque(false); - } - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - - g.setColor(Color.red); - final Graphics2D g2d = (Graphics2D)g; - - int arc1 = 4; - int arc2 = 6; - - final Rectangle r = new Rectangle(arc1, arc1, getWidth() - arc1 - 1, getHeight() - arc1 - 1); - - myT.reset(r); - - myT.moveTo(myT.getX() - myT.deltaX(arc1), myT.getMaxY()); - myT.quadTo(myT.getX(), myT.getMaxY(), myT.getX(), myT.getMaxY() - myT.deltaY(arc1)); - myT.lineTo(myT.getX(), myT.getY() + myT.deltaY(arc2)); - myT.quadTo(myT.getX(), myT.getY(), myT.getX() + myT.deltaX(arc2), myT.getY()); - myT.lineTo(myT.getMaxX() - myT.deltaX(arc2), myT.getY()); - myT.quadTo(myT.getMaxX(), myT.getY(), myT.getMaxX(), myT.getY() + myT.deltaY(arc2)); - myT.lineTo(myT.getMaxX(), myT.getMaxY()); - - g2d.draw(myT.getShape()); - - - final int innerRecSize = 18; - final Rectangle innerRec = new Rectangle(getWidth() / 2 - innerRecSize / 2, getHeight() / 2 - innerRecSize / 2, innerRecSize, innerRecSize); - - final ShapeTransform inner = myT.createTransform(innerRec); - inner.moveTo(inner.getX(), inner.getMaxY()); - inner.lineTo(inner.getX(), inner.getY()); - inner.lineTo(inner.getMaxX(), inner.getY()); - inner.lineTo(inner.getMaxX(), inner.getMaxY()); - - g2d.draw(inner.getShape()); - } - } - - } diff --git a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java index 43a2cb7c59bb..dcea6b11caf5 100644 --- a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java @@ -26,7 +26,6 @@ import com.intellij.openapi.actionSystem.ex.AnActionListener; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.GraphicsConfig; -import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.impl.ShadowBorderPainter; import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.ui.popup.JBPopupListener; @@ -40,7 +39,6 @@ import com.intellij.openapi.wm.impl.IdeGlassPaneEx; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.components.panels.Wrapper; -import com.intellij.ui.treeStructure.Tree; import com.intellij.util.Alarm; import com.intellij.util.IJSwingUtilities; import com.intellij.util.Range; @@ -1479,67 +1477,6 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui, SwingConstants { } } - public static void main(String[] args) { - IconLoader.activate(); - - final JFrame frame = new JFrame(); - frame.getContentPane().setLayout(new BorderLayout()); - final JPanel content = new JPanel(new BorderLayout()); - frame.getContentPane().add(content, BorderLayout.CENTER); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - final JTree tree = new Tree(); - content.add(tree); - - - final Ref balloon = new Ref(); - - tree.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(final MouseEvent e) { - if (balloon.get() != null && balloon.get().isVisible()) { - balloon.get().dispose(); - } - else { - //JLabel pane1 = new JLabel("Hello, world!"); - //JLabel pane2 = new JLabel("Hello, again"); - //JPanel pane = new JPanel(new BorderLayout()); - //pane.add(pane1, BorderLayout.CENTER); - //pane.add(pane2, BorderLayout.SOUTH); - - //pane.setBorder(new LineBorder(Color.blue)); - - balloon.set(new BalloonImpl(new JLabel("FUCK"), Color.black, MessageType.ERROR.getPopupBackground(), true, true, true, true, true, 0, true, null, false, 500, 25, 0, 0, false, "This is the title", - new Insets(2, 2, 2, 2), true, false, false, Layer.normal)); - balloon.get().setShowPointer(true); - - if (e.isShiftDown()) { - balloon.get().show(new RelativePoint(e), ABOVE); - } - else if (e.isAltDown()) { - balloon.get().show(new RelativePoint(e), BELOW); - } - else if (e.isMetaDown()) { - balloon.get().show(new RelativePoint(e), AT_LEFT); - } - else { - balloon.get().show(new RelativePoint(e), AT_RIGHT); - } - } - } - }); - - tree.addMouseMotionListener(new MouseMotionAdapter() { - @Override - public void mouseMoved(MouseEvent e) { - System.out.println(e.getPoint()); - } - }); - - frame.setBounds(300, 300, 300, 300); - frame.show(); - } - @Override public boolean wasFadedIn() { return myFadedIn; diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/ui/LoadingDecoratorTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/ui/LoadingDecoratorTest.java new file mode 100644 index 000000000000..c6ae31fd9685 --- /dev/null +++ b/platform/platform-tests/testSrc/com/intellij/openapi/ui/LoadingDecoratorTest.java @@ -0,0 +1,43 @@ +package com.intellij.openapi.ui; + +import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.IconLoader; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class LoadingDecoratorTest { + public static void main(String[] args) { + IconLoader.activate(); + + final JFrame frame = new JFrame(); + frame.getContentPane().setLayout(new BorderLayout()); + + final JPanel content = new JPanel(new BorderLayout()); + + final LoadingDecorator loadingTree = new LoadingDecorator(new JComboBox(), Disposer.newDisposable(), -1); + + content.add(loadingTree.getComponent(), BorderLayout.CENTER); + + final JCheckBox loadingCheckBox = new JCheckBox("Loading"); + loadingCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent e) { + if (loadingTree.isLoading()) { + loadingTree.stopLoading(); + } else { + loadingTree.startLoading(false); + } + } + }); + + content.add(loadingCheckBox, BorderLayout.SOUTH); + + + frame.getContentPane().add(content, BorderLayout.CENTER); + + frame.setBounds(300, 300, 300, 300); + frame.show(); + } +} diff --git a/platform/platform-tests/testSrc/com/intellij/ui/BalloonTest.java b/platform/platform-tests/testSrc/com/intellij/ui/BalloonTest.java new file mode 100644 index 000000000000..840a4957c307 --- /dev/null +++ b/platform/platform-tests/testSrc/com/intellij/ui/BalloonTest.java @@ -0,0 +1,92 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ui; + +import com.intellij.openapi.ui.MessageType; +import com.intellij.openapi.ui.popup.Balloon; +import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.util.Ref; +import com.intellij.ui.awt.RelativePoint; +import com.intellij.ui.treeStructure.Tree; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; + +public class BalloonTest { + public static void main(String[] args) { + IconLoader.activate(); + + final JFrame frame = new JFrame(); + frame.getContentPane().setLayout(new BorderLayout()); + final JPanel content = new JPanel(new BorderLayout()); + frame.getContentPane().add(content, BorderLayout.CENTER); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + final JTree tree = new Tree(); + content.add(tree); + + + final Ref balloon = new Ref(); + + tree.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(final MouseEvent e) { + if (balloon.get() != null && balloon.get().isVisible()) { + balloon.get().dispose(); + } + else { + //JLabel pane1 = new JLabel("Hello, world!"); + //JLabel pane2 = new JLabel("Hello, again"); + //JPanel pane = new JPanel(new BorderLayout()); + //pane.add(pane1, BorderLayout.CENTER); + //pane.add(pane2, BorderLayout.SOUTH); + + //pane.setBorder(new LineBorder(Color.blue)); + + balloon.set(new BalloonImpl(new JLabel("FUCK"), Color.black, MessageType.ERROR.getPopupBackground(), true, true, true, true, true, 0, true, null, false, 500, 25, 0, 0, false, "This is the title", + new Insets(2, 2, 2, 2), true, false, false, Balloon.Layer.normal)); + balloon.get().setShowPointer(true); + + if (e.isShiftDown()) { + balloon.get().show(new RelativePoint(e), Balloon.Position.above); + } + else if (e.isAltDown()) { + balloon.get().show(new RelativePoint(e), Balloon.Position.below); + } + else if (e.isMetaDown()) { + balloon.get().show(new RelativePoint(e), Balloon.Position.atLeft); + } + else { + balloon.get().show(new RelativePoint(e), Balloon.Position.atRight); + } + } + } + }); + + tree.addMouseMotionListener(new MouseMotionAdapter() { + @Override + public void mouseMoved(MouseEvent e) { + System.out.println(e.getPoint()); + } + }); + + frame.setBounds(300, 300, 300, 300); + frame.show(); + } +} diff --git a/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/ShapeTransformTest.java b/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/ShapeTransformTest.java new file mode 100644 index 000000000000..b4d5049ea44c --- /dev/null +++ b/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/ShapeTransformTest.java @@ -0,0 +1,87 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ui.tabs.impl; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import java.awt.*; + +public class ShapeTransformTest { + private static class Painter extends JLabel { + private final ShapeTransform myT; + + private Painter(String text, ShapeTransform transform) { + setText(text); + setFont(getFont().deriveFont(30f)); + setBorder(new EmptyBorder(6, 6, 6, 6)); + myT = transform; + setOpaque(false); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + g.setColor(Color.red); + final Graphics2D g2d = (Graphics2D)g; + + int arc1 = 4; + int arc2 = 6; + + final Rectangle r = new Rectangle(arc1, arc1, getWidth() - arc1 - 1, getHeight() - arc1 - 1); + + myT.reset(r); + + myT.moveTo(myT.getX() - myT.deltaX(arc1), myT.getMaxY()); + myT.quadTo(myT.getX(), myT.getMaxY(), myT.getX(), myT.getMaxY() - myT.deltaY(arc1)); + myT.lineTo(myT.getX(), myT.getY() + myT.deltaY(arc2)); + myT.quadTo(myT.getX(), myT.getY(), myT.getX() + myT.deltaX(arc2), myT.getY()); + myT.lineTo(myT.getMaxX() - myT.deltaX(arc2), myT.getY()); + myT.quadTo(myT.getMaxX(), myT.getY(), myT.getMaxX(), myT.getY() + myT.deltaY(arc2)); + myT.lineTo(myT.getMaxX(), myT.getMaxY()); + + g2d.draw(myT.getShape()); + + + final int innerRecSize = 18; + final Rectangle innerRec = new Rectangle(getWidth() / 2 - innerRecSize / 2, getHeight() / 2 - innerRecSize / 2, innerRecSize, innerRecSize); + + final ShapeTransform inner = myT.createTransform(innerRec); + inner.moveTo(inner.getX(), inner.getMaxY()); + inner.lineTo(inner.getX(), inner.getY()); + inner.lineTo(inner.getMaxX(), inner.getY()); + inner.lineTo(inner.getMaxX(), inner.getMaxY()); + + g2d.draw(inner.getShape()); + } + } + + + public static void main(String[] args) { + final JFrame frame = new JFrame(); + frame.getContentPane().setLayout(new BorderLayout()); + final JPanel content = new JPanel(new FlowLayout(FlowLayout.CENTER)); + frame.getContentPane().add(content, BorderLayout.CENTER); + + content.add(new Painter("TOP", new ShapeTransform.Top())); + content.add(new Painter("LEFT", new ShapeTransform.Left())); + content.add(new Painter("BOTTOM", new ShapeTransform.Bottom())); + content.add(new Painter("RIGHT", new ShapeTransform.Right())); + + frame.setBounds(300, 300, 300, 300); + frame.show(); + } +}