19 package com.generalrobotix.ui.view;
21 import org.eclipse.jface.action.Action;
22 import org.eclipse.jface.action.IToolBarManager;
23 import org.eclipse.jface.dialogs.MessageDialog;
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.events.FocusEvent;
26 import org.eclipse.swt.events.FocusListener;
27 import org.eclipse.swt.events.ModifyEvent;
28 import org.eclipse.swt.events.ModifyListener;
29 import org.eclipse.swt.layout.GridLayout;
30 import org.eclipse.swt.layout.GridData;
31 import org.eclipse.swt.widgets.Composite;
32 import org.eclipse.swt.widgets.Event;
33 import org.eclipse.swt.widgets.Label;
34 import org.eclipse.swt.widgets.Listener;
35 import org.eclipse.swt.custom.StyledText;
45 @SuppressWarnings(
"serial")
50 private int caretPos_ = -1;
56 super(name, manager_, vp, parent);
57 GridLayout layout =
new GridLayout(1,
true);
58 layout.marginHeight = 0;
59 layout.marginWidth = 0;
60 layout.horizontalSpacing = 0;
61 layout.verticalSpacing = 0;
62 composite_.setLayout(layout);
64 area_ =
new StyledText( composite_, SWT.MULTI|SWT.V_SCROLL|SWT.BORDER );
66 area_.addModifyListener(
new ModifyListener(){
67 public void modifyText(ModifyEvent e) {
68 if(currentItem_!=
null)
69 currentItem_.
setValue(area_.getText());
73 area_.addFocusListener(
new FocusListener() {
74 public void focusGained(FocusEvent e) {
75 if (currentItem_ ==
null)
78 boolean state = MessageDialog.openQuestion(getParent().getShell(),
MessageBundle.
get(
"GrxTextEditorView.dialog.title.reload"),
MessageBundle.
get(
"GrxTextEditorView.dialog.message.reload"));
81 area_.setText(currentItem_.
getValue());
86 public void focusLost(FocusEvent e) {
90 area_.addListener(SWT.Paint,
new Listener() {
91 public void handleEvent(Event event) {
96 area_.addListener(SWT.MouseDown,
new Listener() {
97 public void handleEvent(Event event) {
102 area_.addListener(SWT.KeyDown,
new Listener() {
103 public void handleEvent(Event event) {
108 status_ =
new Label(composite_, SWT.BORDER);
110 GridData textData =
new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
111 area_.setLayoutData(textData);
113 GridData statusData =
new GridData(GridData.FILL_HORIZONTAL);
114 statusData.verticalAlignment = SWT.END;
115 status_.setLayoutData(statusData);
118 IToolBarManager toolbar = vp.getViewSite().getActionBars().getToolBarManager();
120 save_ =
new Action() {
122 if (currentItem_ !=
null) {
123 currentItem_.
setValue(area_.getText());
131 toolbar.add( save_ );
133 saveAs_ =
new Action() {
135 if (currentItem_ !=
null) {
136 currentItem_.
setValue(area_.getText());
141 saveAs_.setToolTipText(
MessageBundle.
get(
"GrxTextEditorView.text.saveAs") );
143 toolbar.add( saveAs_ );
144 setScrollMinSize(SWT.DEFAULT,SWT.DEFAULT);
153 setTextItem(currentItem_);
158 area_.setText( (String)item.
getValue() );
159 area_.setEnabled(
true);
160 save_.setEnabled(
true);
161 saveAs_.setEnabled(
true);
165 area_.setEnabled(
false);
166 save_.setEnabled(
false);
167 saveAs_.setEnabled(
false);
173 if(caretPos_ == area_.getCaretOffset())
175 caretPos_ = area_.getCaretOffset();
176 int y = area_.getLineAtOffset(caretPos_);
177 String s = area_.getText();
182 char cha = s.charAt(ti);
183 if(cha ==
'\r' || cha ==
'\n'){
188 status_.setText(String.format(
"%6d:%d", y + 1, x + 1));
195 currentItem_ = textItem;
196 setTextItem(textItem);
200 if(currentItem_ == textItem){
static final String get(String key)
void registerItemChange(GrxBaseItem item, int event)
#define null
our own NULL pointer
boolean isModifiedExternally()
png_infop png_charpp name
void registerItemChangeListener(GrxItemChangeListener view, Class<? extends GrxBaseItem > cls)
void setTextItem(GrxPythonScriptItem item)
static final int SELECTED_ITEM
static Activator getDefault()
static final int REMOVE_ITEM
GrxTextEditorView(String name, GrxPluginManager manager_, GrxBaseViewPart vp, Composite parent)
Font getFont(String fontName)
プラグイン管理クラス GrxUIの核になるクラス。プラグインのロード等の、初期化を実行する。 プラグインとそ...
static final int NOTSELECTED_ITEM
ImageDescriptor getDescriptor(String iconName)