1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.adapter;
14 import java.awt.Color;
15 import java.awt.Frame;
17 import javax.swing.BorderFactory;
18 import javax.swing.BoxLayout;
19 import javax.swing.JLabel;
20 import javax.swing.JPanel;
22 import org.simantics.g2d.element.ElementUtils;
23 import org.simantics.g2d.element.IElement;
24 import org.simantics.g2d.tooltip.AWTTooltipProvider;
26 public class DefinedElementTooltipProvider extends AWTTooltipProvider {
28 public static DefinedElementTooltipProvider INSTANCE = new DefinedElementTooltipProvider();
31 public void constructPopup(Frame frame, IElement element) {
32 frame.setLayout(new BoxLayout(frame, BoxLayout.X_AXIS));
33 JPanel panel = new JPanel();
34 panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
35 Color c = new Color(255, 255, 220);
36 panel.setBackground(c);
37 panel.setBorder(BorderFactory.createLineBorder(Color.black));
38 JLabel label = new JLabel(ElementUtils.getText(element));