我试图在Eclipse RCP中获取一个shell并在我的应用程序中调出弹出窗口,并通过几个资源/教程来完成任务但没有太多运气.
Display.getCurrent().getActiveShell();
Run Code Online (Sandbox Code Playgroud)
要么
Display.getDefault().getActiveShell();
Run Code Online (Sandbox Code Playgroud)
要么
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
Run Code Online (Sandbox Code Playgroud)
有时甚至是
Display.getDefault().getShells()[0];
Run Code Online (Sandbox Code Playgroud)
但是不同的事情似乎在不同的情况下起作用.
在线资源有不同的观点,我发现大多数事情说你根本不应该真正使用这个Display类,但我试图在日食工作中提出一个弹出窗口.它已经结束并失败,弹出窗口需要显示:
Display.getCurrent().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Publish", e.getMessage());
}
});
}
Run Code Online (Sandbox Code Playgroud)
弹出窗口是从从Eclipse作业启动的线程执行的Runnable内部.这很复杂但是必须在服务器上调用同步方法时提供进度条更新.
它不起作用,我不知道为什么.从getActiveShell()调用中获取null.
真正的问题不是'为什么我的代码不能正常工作',而是在Eclipse RCP框架中为弹出窗口获取shell的确切正确方法,特别是在无法访问工作台的情况下?
我一直在玩Zest GraphViewer超过一个星期,现在试图发现它可以为我的应用程序做些什么,但到目前为止我还没有能够满足我的要求.
我希望有人可以指出我需要的资源,因为我无法找到与Google一起使用的所有资源,或者可以告诉我我的想法是否可行.
版
我已经在RCP项目的依赖项中获得了Zest核心1.3.0和Zest布局1.1.0.这来自我从Zest网站上下载的网站.
要求
右键单击功能可以来自单一选择,因为我可以在任何地方使用弹出窗口,但是它基于当前所选节点,但我宁愿不这样做.
由于性质或我们的应用程序和用户,我无法做到这一点,我可能还需要找到另一个具有此功能的基于RCP/SWT的Graph绘图包.
任何这些问题的任何帮助将不胜感激.
格伦x
我正在搜索SWT中的组合框的实现,这将允许我使用任何对象的列表设置其中的条目,类似于树和表.
理想情况下,我希望String在下拉时能够与选择后的最终String不同.IE下拉菜单选择一个人在列表中显示他们姓名旁边的年龄,但只选择他们的姓名并放在框中.
所有我能发现存在的是基于字符串的组合框,无法描述不同的显示选项,所以我想我必须构建一个新的组件,如果我想要的东西工作,但我希望有人已经实现了这样的事(因为我在某些应用程序中看到过这种功能)而我却找不到它?
我希望创造这样的东西.

我正在运行一个spring数据neo-4j应用程序(不是基于web的),它在正常操作期间工作正常.
如果我关闭Spring Context'ctx.close()',neo 4J数据库上的锁就会消失.
然后,从应用程序的同一个实例,如果我抓住另一个上下文,我看到锁回来了,但如果我尝试从该上下文中读取/写入该数据库,我会收到一个错误:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': Unsatisfied dependency expressed through bean property 'conversionService': : Error creating bean with name 'mappingInfrastructure' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public final org.springframework.data.neo4j.support.MappingInfrastructureFactoryBean org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$64cefd6f.mappingInfrastructure() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'typeRepresentationStrategyFactory' defined in class org.springframework.data.neo4j.config.Neo4jConfiguration: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public final org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$64cefd6f.typeRepresentationStrategyFactory() throws java.lang.Exception] threw exception; …Run Code Online (Sandbox Code Playgroud) 嗨,我有一个简单的DAO具有以下功能.
public element createElement(Element e){
em.persist(e);
em.flush();
return e;
}
Run Code Online (Sandbox Code Playgroud)
Entity表对该对具有唯一约束(类型,值),我在下面进行了测试:
public void testCreateElement() throws DataAccessException {
// Start with empty Element table
Element e = new Element();
e.setType(myType.OTHER);
e.setValue("1");
dao.createElement(e);
e = new Element();
e.setType(MyType.OTHER);
e.setValue("1");
try{
// this should violate unique constraint of database.
dao.createElement(e);
} catch (Exception ex) {
System.out.println(ex);
}
e.setValue("2");
try{
// I expect this to work as there is no element with these values.
dao.createElement(e);
} catch (Exception ex) {
System.out.println(ex);
}
}
Run Code Online (Sandbox Code Playgroud)
我发现第一个被发现的错误就像我预期的那样,因为我知道我违反了约束,第二次尝试/ …
所以我有一个问题,当我将图像添加到JFace表的任何列时,第一列的行为就像它有一个图像,文本缩进了该图像的大小.
这是一个截图,说明了生成它所需代码的观点.反正有没有阻止它发生,因为它真的在我的灯芯上?
问候,
格伦x

package widgets;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.StyledCellLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class ComponentTest {
private static Image image;
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, true));
TableViewer viewer1 = getViewer(shell, true);
TableViewer viewer2 = getViewer(shell, false);
List<String> rows = new ArrayList<String>(); …Run Code Online (Sandbox Code Playgroud) 在我的Eclipse RCP应用程序中,我有一个TreeViewer,它是文件的放置目标,它在大多数情况下工作正常,但是当我尝试将存储在CD ROM上的文件从Windows资源管理器拖到节点时,指示丢弃的图标是允许的改变和放弃什么都不做.
由于人们似乎对我的问题感到困惑,这里有一个更详细的解释:
当执行下面的代码(由Baz提供)时,我能够拖动文件并将它们放到文本框中,当我从我的机器上的大多数位置拖动文件时,窗口显示如下 - >

光标表示我可以丢弃,当我释放鼠标时,drop(DropTargetEvent event)调用该方法.
现在,当我做同样的事情,但从我的光驱中的DVD上的资源管理器中获取文件时,它看起来像这样:

指示不允许丢弃,并且当我释放鼠标时,drop(DropTargetEvent event)不调用该方法.
还值得注意的是,我能够将相同的DVD文件放入eclipse导航器中的文件夹中,表明这不是机器特定的问题,在日食树中必须有不同的东西允许它,但我可以'看到了.
package widgets;
import java.util.Arrays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.PluginTransfer;
public class SourceTest {
public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1,false));
final Text text = new Text(shell, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, …Run Code Online (Sandbox Code Playgroud) 我不确定是否有办法做到这一点,但我想有一个仅对实现特定接口的类有效的类注释。
注释的目的是让管理器知道它需要将该类的实例添加到其托管对象集中。因此,如果无法在编译时添加该限制,那么在运行时处理此问题的最佳模式是什么?
背景: 目前我有一个应用程序,它允许用户在 Strings[] 上执行一组预定义的操作,导致单个字符串输出,这些操作按场景分组,并且每个场景都有一个枚举,定义了这些操作,以及一个在这些枚举上有一个开关来调用单个方法(都在该类中)的类,这意味着添加单个操作涉及对代码中多个区域的更改,我想通过允许新手开发人员来提高它的可维护性只需要知道他们需要编写的单个类会将操作添加到正确的列表中并自动可用。
我决定的解决方案是拥有一个开发人员将实现的 Action 接口,然后添加一个注释以将该 Action 注册到所需的场景/场景中,隔离对创建单个类的任何新更改。
我试图在已经存在的图像的顶部绘制组合形状的透明蒙版.我通过本文中包含的对话框代码提供了我正在尝试的技术示例.这是它产生的截图.
示例1(左上角)突出显示我想要解决的问题,我希望有2个圆圈或任何相交的形状/弧线,所有绘制都与相同的alpha级别一起绘制,即没有因绘制顶部而导致的复合不透明度彼此.
示例3(左下角)是我尝试通过创建一个单独的图像和固体形状来解决问题,然后使整个图像透明,我认为使用这种技术会产生一个图像,其中白色被视为透明颜色,所以圆的边缘与白色混合,这样当你在它上面绘制时会在形状周围产生"光晕"效果.
示例2(左上角)通过将图像中的圆圈绘制为透明来进一步突出显示此问题,因此您可以看到由突出显示引起的更粉红色.
我的问题是,如果不了解背景颜色,并且没有关闭抗锯齿,我怎样才能达到我想要的效果?有没有办法,因为我所有的研究都是空白的?也许我需要使用不同的图像绘制解决方案并返回SWT?我知道如果直接从文件加载它能够绘制透明图像,所以我知道它可以保存这种数据,但我该如何创建它?
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class FMLDialog extends Dialog
{
private Color red;
private Color blue;
public FMLDialog(Shell parentShell)
{
super(parentShell);
}
@Override
protected void configureShell(Shell shell)
{
red = new Color(shell.getDisplay(), new RGB(255,0,0));
blue = new Color(shell.getDisplay(), new RGB(0,100,255));
super.configureShell(shell);
shell.setSize(new Point(450,550));
shell.setText("FML");
} …Run Code Online (Sandbox Code Playgroud) 所以昨天我问了这个问题,但目标职位已经改变,问题不同了:
我想知道是否可以创建将模拟我所需关系的实体,以便Hibernate在我启动应用程序时创建我的模式.
我想要的关系看起来像这样:
问题是Join表实际上可以包含不链接到任何Elements的行.该结构表示基于"类型"和"值"对的元素分类,并输入到该特定应用之外的系统中.
我希望能够做的是通过映射将我的元素Hibernate实体设置为包含类别列表,这样我就可以实际看到我的元素所属的类别,以便hibernate为我创建表格.
这是我到目前为止所做的:在我的Element Entity类中映射这样:
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "ELEMENT_ELEMENTCATOGORY", joinColumns = {
@JoinColumn(name = "type", referencedColumnName = "type"),
@JoinColumn(name = "value", referencedColumnName = "value") })
@Column(name = "category")
public List<ElementCategory> getCategories() {
return categories;
}
Run Code Online (Sandbox Code Playgroud)
这完成了我想要的大部分内容,它创建了我的表格,如上所述,我想要的只是一个东西,在(类型,值)对的元素表中添加了一个唯一约束.我不希望这样,因为多个元素可以具有相同的类型和值对,我需要能够从开始创建中停止Unique Constraint,但是无法弄清楚当前映射的方式,我可以这样做吗?我错过了多对多关系的观点吗?
java ×10
swt ×5
eclipse-rcp ×4
hibernate ×2
annotations ×1
combobox ×1
eclipse ×1
graph ×1
jface ×1
jpa ×1
many-to-many ×1
neo4j ×1
persist ×1
popup ×1
spring-data ×1
spring-mvc ×1
tableviewer ×1
windows ×1
zest ×1