KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > lifl > eclipse > plugin > shell > views > OpenCCMConsole


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Offroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.omg.lifl.eclipse.plugin.shell.views;
27
28 import java.util.Vector JavaDoc;
29
30 import org.eclipse.jface.dialogs.MessageDialog;
31 import org.eclipse.jface.text.Document;
32 import org.eclipse.jface.text.TextViewer;
33 import org.eclipse.swt.graphics.Color;
34 import org.eclipse.swt.graphics.Point;
35 import org.eclipse.swt.layout.GridData;
36 import org.eclipse.swt.widgets.Composite;
37 import org.eclipse.ui.part.ViewPart;
38
39 /**
40  * This class plug-in a new workbench view for OpenCCM use.
41  * <p>
42  */

43
44 public class OpenCCMConsole extends ViewPart {
45     private TextViewer viewer;
46     private Document document;
47     public static final String JavaDoc CONSOLE_ID = "org.omg.lifl.eclipse.plugin.shell.views.OpenCCMConsole";
48
49     /**
50      * The constructor.
51      */

52     public OpenCCMConsole() {
53         viewer = null;
54         document = null;
55     }
56
57     /**
58      * This is a callback that will allow us
59      * to create the viewer and initialize it.
60      */

61     public void createPartControl(Composite parent) {
62         viewer =
63             new TextViewer(parent, 832); //TODO find code 832 SWT.
64
GridData viewerData = new GridData(1808);
65         viewer.getControl().setLayoutData(viewerData);
66         viewer.setEditable(false);
67
68     }
69
70     private void showMessage(String JavaDoc message) {
71         MessageDialog.openInformation(
72             viewer.getControl().getShell(),
73             "OpenCCM Console View",
74             message);
75     }
76
77     /**
78      * Passing the focus request to the viewer's control.
79      */

80     public void setFocus() {}
81
82     public void clear()
83     {
84         viewer.setDocument(null);
85     }
86
87     public void refresh(String JavaDoc string, Vector JavaDoc errorHighlight)
88     {
89         document = new Document(string);
90         viewer.setDocument(document);
91         try
92         {
93             for(int i = 0; i < errorHighlight.size(); i++)
94             {
95                 Point highlightRange = (Point)errorHighlight.elementAt(i);
96                 viewer.setTextColor(new Color(null, 255, 25, 20), highlightRange.x, highlightRange.y, false);
97             }
98
99         }
100         catch(Exception JavaDoc e)
101         {
102             e.printStackTrace();
103         }
104         int numLines = document.getNumberOfLines();
105         viewer.setTopIndex(numLines);
106     }
107
108     
109     
110     /**
111      * @return
112      */

113     public TextViewer getViewer() {
114         return viewer;
115     }
116
117     /**
118      * @param viewer
119      */

120     public void setViewer(TextViewer viewer) {
121         this.viewer = viewer;
122     }
123
124 }
Popular Tags