]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementTooltipProvider.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / adapter / DefinedElementTooltipProvider.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.diagram.adapter;
13
14 import java.awt.Color;
15 import java.awt.Frame;
16
17 import javax.swing.BorderFactory;
18 import javax.swing.BoxLayout;
19 import javax.swing.JLabel;
20 import javax.swing.JPanel;
21
22 import org.simantics.g2d.element.ElementUtils;
23 import org.simantics.g2d.element.IElement;
24 import org.simantics.g2d.tooltip.AWTTooltipProvider;
25
26 public class DefinedElementTooltipProvider extends AWTTooltipProvider {
27         
28         public static DefinedElementTooltipProvider INSTANCE = new DefinedElementTooltipProvider();
29         
30         @Override
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));
39                 panel.add(label);
40                 frame.add(panel);
41         }
42
43 }