if ("stop".equals(e.getActionCommand())) {
if (previewPanel != null && !firstPreview) {
JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(label);
if (frame != null) {
GlassPanel glassPane = descriptor.getManager().getGlassPanel();
glassPane.remove(previewPanel);
SwingUtil.repaint(glassPane);
glassPane.setVisible(false);
SwingUtil.repaint(frame);
previewPanel = null;
}
}
firstPreview = false;
} else if (dockedTypeDescriptor.isPreviewEnabled()) {
Container contentContainer = ((DockedContainer) descriptor.getToolWindowContainer()).getContentContainer();
int width = 176;
int height = 132;
// Show Preview
RootPaneContainer rootPaneContainer = (RootPaneContainer) SwingUtilities.getWindowAncestor(label);
if (rootPaneContainer != null) {
JMenuBar jMenuBar = rootPaneContainer instanceof JFrame ?
((JFrame) rootPaneContainer).getJMenuBar() : null;
firstPreview = true;
previewTimer.stop();
GlassPanel glassPane = descriptor.getManager().getGlassPanel();
if (previewPanel != null)
glassPane.remove(previewPanel);
previewPanel = new TranslucentPanel(new ExtendedTableLayout(new double[][]{{2, TableLayout.FILL, 2}, {2, TableLayout.FILL, 2}}));
previewPanel.setAlphaModeRatio(dockedTypeDescriptor.getPreviewTransparentRatio());
previewPanel.setSize(width + 4, height + 4);
Container mainContainer = descriptor.getManager();
switch (descriptor.getToolWindow().getAnchor()) {
case LEFT:
previewPanel.setLocation(
mainContainer.getX() +
label.getX() + label.getWidth() + 3,
(jMenuBar != null ? jMenuBar.getHeight() : 0) +
mainContainer.getY() +
label.getY() +
(descriptor.getToolBar(TOP).getAvailableTools() != 0 ? 23 : 0)
);
break;
case TOP:
previewPanel.setLocation(
mainContainer.getX() +
label.getX() +
(descriptor.getToolBar(LEFT).getAvailableTools() != 0 ? 23 : 0),
(jMenuBar != null ? jMenuBar.getHeight() : 0) +
mainContainer.getY() +
label.getY() + label.getHeight() + 3
);
break;
case BOTTOM:
previewPanel.setLocation(
mainContainer.getX() +
label.getX() +
(descriptor.getToolBar(LEFT).getAvailableTools() != 0 ? 23 : 0),
(jMenuBar != null ? jMenuBar.getHeight() : 0) +
mainContainer.getY() +
mainContainer.getHeight() -
previewPanel.getHeight() - 26
);
break;
case RIGHT:
previewPanel.setLocation(
mainContainer.getX() +
mainContainer.getWidth() -
previewPanel.getWidth() - 26,
(jMenuBar != null ? jMenuBar.getHeight() : 0) +
mainContainer.getY() +
label.getY() +
(descriptor.getToolBar(TOP).getAvailableTools() != 0 ? 23 : 0)
);
break;
}
if (previewPanel.getY() + previewPanel.getHeight() >
mainContainer.getY() + mainContainer.getHeight() - 26) {
previewPanel.setLocation(
previewPanel.getX(),
(jMenuBar != null ? jMenuBar.getHeight() : 0) +
mainContainer.getY() +
mainContainer.getHeight() -
(descriptor.getToolBar(BOTTOM).getAvailableTools() != 0 ? 23 : 0) -
previewPanel.getHeight() - 3
);
}
if (previewPanel.getX() + previewPanel.getWidth() >
mainContainer.getX() + mainContainer.getWidth() - 26) {
previewPanel.setLocation(
mainContainer.getX() +
mainContainer.getWidth() -
(descriptor.getToolBar(RIGHT).getAvailableTools() != 0 ? 23 : 0) -
previewPanel.getWidth() - 3,
previewPanel.getY()
);
}
previewPanel.add(contentContainer, "1,1,FULL,FULL");
glassPane.add(previewPanel);
glassPane.setVisible(true);
SwingUtil.repaint(glassPane);
}
}
}