javax.swing.JInternalFrame.JDesktopIcon Java Examples

The following examples show how to use javax.swing.JInternalFrame.JDesktopIcon. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TitlePaneIconifyButtonWindowMinimizedState.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean isInState(JComponent c) {
    Component parent = c;

    while (parent.getParent() != null) {

        if (parent instanceof JInternalFrame || parent instanceof JDesktopIcon) {
            break;
        }

        parent = parent.getParent();
    }

    if (parent instanceof JInternalFrame) {
        return ((JInternalFrame) parent).isIcon();
    } else if (parent instanceof JDesktopIcon) {
        return true;
    }

    return false;
}
 
Example #2
Source File: SubstanceDesktopIconUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Installs the UI delegate on the desktop icon if necessary.
 * 
 * @param jdi
 *            Desktop icon.
 */
void installIfNecessary(JDesktopIcon jdi) {
	// fix for issue 344 - reopening an internal frame
	// that has been closed.
	if (this.desktopIcon == null) {
		this.installUI(jdi);
	}
}
 
Example #3
Source File: SubstanceDesktopIconUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Uninstalls the UI delegate from the desktop icon if necessary.
 * 
 * @param jdi
 *            Desktop icon.
 */
void uninstallIfNecessary(JDesktopIcon jdi) {
	// fix for issue 345 - an internal frame used in inner option pane
	// gets closed twice
	if (this.desktopIcon == jdi) {
		this.uninstallUI(jdi);
	}
}
 
Example #4
Source File: JInternalFrameOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Searches JInternalframe in container.
 *
 * @param cont Container to search component in.
 * @param chooser a component chooser specifying searching criteria.
 * @param index Ordinal component index.
 * @return JInternalframe instance or null if component was not found.
 */
public static JInternalFrame findJInternalFrame(Container cont, ComponentChooser chooser, int index) {
    Component res = findComponent(cont, new JInternalFrameFinder(chooser), index);
    if (res instanceof JInternalFrame) {
        return (JInternalFrame) res;
    } else if (res instanceof JInternalFrame.JDesktopIcon) {
        return ((JInternalFrame.JDesktopIcon) res).getInternalFrame();
    } else {
        return null;
    }
}
 
Example #5
Source File: JInternalFrameOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Waits JInternalframe in container.
 *
 * @param cont Container to search component in.
 * @param chooser a component chooser specifying searching criteria.
 * @param index Ordinal component index.
 * @return JInternalframe instance.
 *
 */
public static JInternalFrame waitJInternalFrame(final Container cont, final ComponentChooser chooser, final int index) {
    Component res = waitComponent(cont, new JInternalFrameFinder(chooser), index);
    if (res instanceof JInternalFrame) {
        return (JInternalFrame) res;
    } else if (res instanceof JInternalFrame.JDesktopIcon) {
        return ((JInternalFrame.JDesktopIcon) res).getInternalFrame();
    } else {
        throw (new TimeoutExpiredException(chooser.getDescription()));
    }
}
 
Example #6
Source File: JInternalFrameOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JInternalFrame.getDesktopIcon()} through queue
 */
public JDesktopIcon getDesktopIcon() {
    return (runMapping(new MapAction<JDesktopIcon>("getDesktopIcon") {
        @Override
        public JDesktopIcon map() {
            return ((JInternalFrame) getSource()).getDesktopIcon();
        }
    }));
}
 
Example #7
Source File: JInternalFrameOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JInternalFrame.setDesktopIcon(JDesktopIcon)} through queue
 */
public void setDesktopIcon(final JDesktopIcon jDesktopIcon) {
    runMapping(new MapVoidAction("setDesktopIcon") {
        @Override
        public void map() {
            ((JInternalFrame) getSource()).setDesktopIcon(jDesktopIcon);
        }
    });
}
 
Example #8
Source File: JInternalFrameOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static JInternalFrame findOne(ContainerOperator<?> cont, String text, int index) {
    Component source = waitComponent(cont,
            new JInternalFrameByTitleFinder(text,
                    cont.getComparator()),
            index);
    if (source instanceof JInternalFrame) {
        return (JInternalFrame) source;
    } else if (source instanceof JInternalFrame.JDesktopIcon) {
        return ((JInternalFrame.JDesktopIcon) source).getInternalFrame();
    } else {
        throw (new TimeoutExpiredException("No internal frame was found"));
    }
}
 
Example #9
Source File: SubstanceInternalFrameTitlePane.java    From radiance with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void paintComponent(Graphics g) {
    Graphics2D graphics = (Graphics2D) g.create();
    // Desktop icon is translucent.
    final float coef = (this.getParent() instanceof JDesktopIcon) ? 0.9f : 1.0f;
    graphics.setComposite(WidgetUtilities.getAlphaComposite(this.frame, coef, g));

    boolean leftToRight = this.frame.getComponentOrientation().isLeftToRight();

    int width = this.getWidth();
    int height = this.getHeight() + 2;

    SubstanceColorScheme scheme = SubstanceCoreUtilities.getSkin(this.frame)
            .getEnabledColorScheme(DecorationAreaType.SECONDARY_TITLE_PANE);
    JInternalFrame hostFrame = (JInternalFrame) SwingUtilities
            .getAncestorOfClass(JInternalFrame.class, this);
    JComponent hostForColorization = hostFrame;
    if (hostFrame == null) {
        // try desktop icon
        JDesktopIcon desktopIcon = (JDesktopIcon) SwingUtilities
                .getAncestorOfClass(JDesktopIcon.class, this);
        if (desktopIcon != null)
            hostFrame = desktopIcon.getInternalFrame();
        hostForColorization = desktopIcon;
    }
    Color backgr = hostFrame.getBackground();
    if (!(backgr instanceof UIResource)) {
        double colorization = SubstanceCoreUtilities.getColorizationFactor(hostForColorization);
        scheme = SubstanceColorSchemeUtilities.getShiftedScheme(scheme, backgr, colorization,
                null, 0.0);
    }

    BackgroundPaintingUtils.update(graphics, SubstanceInternalFrameTitlePane.this, false);

    String theTitle = this.frame.getTitle();
    String displayTitle = getDisplayTitle();

    Font font = SubstanceCortex.GlobalScope.getFontPolicy().getFontSet().getWindowTitleFont();
    graphics.setFont(font);

    if (displayTitle != null) {
        Rectangle titleTextRect = SubstanceTitlePaneUtilities.getTitlePaneTextRectangle(this,
                this.frame);
        FontMetrics fm = SubstanceMetricsUtilities.getFontMetrics(font);
        int displayTitleWidth = fm.stringWidth(displayTitle);

        // show tooltip with full title only if necessary
        if (theTitle.equals(displayTitle)) {
            this.setToolTipText(null);
        } else {
            this.setToolTipText(theTitle);
        }

        int xOffset = 0;
        SubstanceSlices.HorizontalGravity titleTextGravity = SubstanceTitlePaneUtilities
                .getTitlePaneTextGravity();
        switch (titleTextGravity) {
            case LEADING:
                xOffset = leftToRight ? titleTextRect.x
                        : titleTextRect.x + titleTextRect.width - displayTitleWidth;
                break;
            case TRAILING:
                xOffset = leftToRight
                        ? titleTextRect.x + titleTextRect.width - displayTitleWidth
                        : titleTextRect.x;
                break;
            default:
                xOffset = titleTextRect.x + (titleTextRect.width - displayTitleWidth) / 2;
        }

        int yOffset = titleTextRect.y + (int) ((titleTextRect.getHeight() - fm.getHeight()) / 2)
                + fm.getAscent();

        SubstanceColorScheme fillScheme = SubstanceCoreUtilities.getSkin(this.frame)
                .getBackgroundColorScheme(DecorationAreaType.SECONDARY_TITLE_PANE);
        Color echoColor = !fillScheme.isDark() ? fillScheme.getUltraDarkColor()
                : fillScheme.getUltraLightColor();
        SubstanceTextUtilities.paintTextWithDropShadow(this, graphics,
                SubstanceColorUtilities.getForegroundColor(scheme), echoColor, displayTitle,
                width, height, xOffset, yOffset);
    }

    graphics.dispose();
}
 
Example #10
Source File: JInternalFrameOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs JDesktopIconOperator.
 *
 * @param b a component
 */
public JDesktopIconOperator(JInternalFrame.JDesktopIcon b) {
    super(b);
    setOutput(JemmyProperties.getCurrentOutput());
    setTimeouts(JemmyProperties.getCurrentTimeouts());
}
 
Example #11
Source File: JInternalFrameOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean checkComponent(Component comp) {
    return ((comp instanceof JInternalFrame || comp instanceof JInternalFrame.JDesktopIcon)
            && sf.checkComponent(comp));
}