我想在我创建的新编辑器上切换断点。我有一个新的编辑器和一个新的LineBreakpoint实现和运行。我已经可以用 Ctrl + Shift + B 或主菜单 - >来切换这些断点。运行 - >切换线断点。我希望能够在我的自定义eclipse应用程序的垂直标尺栏中添加Java编辑器中的切换行为。也就是说,双击创建/切换给定行位置的断点。右键单击会打开切换断点菜单上下文(在垂直标尺栏上)。也可以使用线切换图像标签。
我假设有一种简单的方法来执行此操作,而不是实现每个菜单和操作。如果没有,我如何将这些双击和上下文菜单添加到自定义编辑器的垂直标尺?
答案 0 :(得分:0)
我正在考虑做同样的事情。到目前为止,我发现扩展AbstractDecoratedTextEditor将为您提供执行此操作的平台。我会在工作时更新。
答案 1 :(得分:0)
这是一个老问题,但我遇到了这个问题,并且做到了这一点:
我有一个编辑器(org.eclipse.ui.texteditor.AbstractDecoratedTextEditor)。在这个编辑器类中,我实现了这个方法:
import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
import org.eclipse.jface.text.source.AnnotationRulerColumn;
import org.eclipse.jface.text.source.IAnnotationAccess;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
public class MyAnnotationRulerColumn extends AnnotationRulerColumn {
private MyEditor editor;
public MyAnnotationRulerColumn(int width, IAnnotationAccess annotationAccess, MyEditor part) {
super(width, annotationAccess);
this.editor = part;
}
@Override
protected void mouseDoubleClicked(int rulerLine) {
if (editor != null) {
IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) editor.getAdapter(IVerticalRulerInfo.class);
ToggleBreakpointAction action = new ToggleBreakpointAction(editor, null, rulerInfo);
action.update();
action.run();
}
}
}
类MyAnnotationRulerColumn有点像这样想:
using System;
using System.IO;
using System.Collections;
using System.Timers;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Graphics;
namespace TestSpeedWithXamarin
{
[Activity(Label = "TestBattteryWithXamarin", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
Timer t;
ArrayList imagesArray;
int actualImage;
ImageView imageView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
string rutaInicial = "sdcard/DCIM/Camera";
imagesArray = new ArrayList();
try
{
DirectoryInfo di = new DirectoryInfo(rutaInicial);
foreach (var item in di.GetFileSystemInfos())
{
if (item.Extension == ".jpg" || item.Extension == ".png")
imagesArray.Add(item.FullName);
}
}
catch (Exception ex)
{
Toast.MakeText(this, "problem ", ToastLength.Long).Show();
}
if (imagesArray.Count > 0)
{
t = new Timer(2000);
t.Elapsed += OnTimedEvent;
actualImage = 0;
t.Enabled = true;
mostrarImagen((String)imagesArray[0]);
}
}
private void OnTimedEvent(Object source,ElapsedEventArgs e) {
if (actualImage < imagesArray.Count-1)
{
actualImage++;
//imageView = FindViewById<ImageView>(Resource.Id.imageView1);
Bitmap imageBitmap = BitmapFactory.DecodeFile((String)imagesArray[actualImage]);
imageView.SetImageBitmap(imageBitmap);
t.Start();
}
}
private void mostrarImagen(string imagePath) {
imageView = FindViewById<ImageView>(Resource.Id.imageView1);
Bitmap imageBitmap = BitmapFactory.DecodeFile(imagePath);
imageView.SetImageBitmap(imageBitmap);
}
}
}