我正在为我的主GUI添加一个表.它确实显示并且具有它想要显示的数据.但我觉得我的代码很乱,而且结构不正确.我正在寻找一个使用SWT的人来帮助我将正确的代码放在正确的位置.
A类 - 主GUI TableViewer
B类 - (ArrayList
)表格/ B1类数据 - ArrayList
结构数据模型
A类 - 有创造方法 TableViewer
//////////////////////////////////////////////////////////////////////////
// createTableViewer() //
//////////////////////////////////////////////////////////////////////////
private TableViewer createTableViewer(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
createColumns(parent, viewer);
table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
// Layout the viewer
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
viewer.setContentProvider(new ArrayContentProvider());
*** Getting Array from Class B ***
viewer.setInput(AplotDataModel.getInstance().getArrayData());
viewer.getControl().setLayoutData(gridData);
return viewer;
}
Run Code Online (Sandbox Code Playgroud)
A类也有createColumns()
方法和createTableViewerColumn()
方法.
////////////////////////////////////////////////////////////////////////// …
Run Code Online (Sandbox Code Playgroud) 是否可以向表格中的单元格添加" 删除"按钮?
我有一个包含5列的表,我想添加第6列.我希望第6列在每行中都有一个删除按钮.
示例行:
| 10002 | 部分| 金属| 001 | 是的| Remove |
这样,用户只需单击按钮即可删除任何不需要的行.
我在表中有一个标记列,它是ComboBox
.我创建了一个扩展的类EditingSupport
.
我是否需要扩展另一个类EditingSupport
,但是创建一个按钮而不是ComboBox
?
编辑
public class AplotDataTableViewer extends TableViewer
{
public AplotDataTableViewer(Composite parent, int style)
{
super(parent, style);
Table table = getTable();
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
table.setLayoutData(gridData);
createColumns();
table.setHeaderVisible(true);
table.setLinesVisible(true);
setContentProvider(new ArrayContentProvider());
}
private void createColumns() {
String[] titles = { "ItemId", "RevId", "PRL", "Dataset Name", "EC Markup" };
int[] bounds = { …
Run Code Online (Sandbox Code Playgroud) 我正在使用SWT创建一个新项目.我将在项目中有3或4个不同的表.我对SWT很新,我发现自己要问我应该使用Table
或者它应该是一个TableViewer
.
我想学习一些关于何时使用Table
和何时TableViewer
是最佳路线的良好指导.
TableViewer
而不是a 的好处是Table
什么?TableViewer
吗?Table
是最好的方法吗?只是真的想要一些清晰度,所以当我创建项目时,我会以正确的方式做到这一点.
编辑
我创建了一个Tablemodel
我用于第一个表的类.但该createColumns
方法专用于该特定表.
是否可以拥有模板TableViewer
类?
我可以将方法更改为更适用于不同的表吗?
以下是该方法的片段:
private void createColumns() {
String[] titles = { "ItemId", "RevId", "PRL", "Dataset Name", "EC Markup" };
int[] bounds = { 150, 150, 100, 150, 100 };
TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);
col.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
if(element instanceof AplotDataModel.AplotDatasetData)
return ((AplotDataModel.AplotDatasetData)element).getDataset().toString();
return …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在开始操作时更改光标.我希望光标显示为忙,直到操作完成.我有一个单独的类用于operationListener.我不知道如何分配光标?
从AplotBaseDialog类调用
listOp.addOperationListener(new MyOperationListener(this) {
etc....
}
Run Code Online (Sandbox Code Playgroud)
单独的类
public abstract class MyOperationListener implements InterfaceAIFOperationListener {
Cursor busyCursor = null;
AplotBaseDialog w = null;
public MyOperationListener(AplotBaseDialog win) {
**Should this not be getCurrent?**
busyCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT);
w = win;
} // end constructor
public void startOperation(String startMessage) {
** should this be getting a Shell form the AplotBaseDialog? **
w.???.setCursor(busyCursor);
} // end startOperation()
public void endOperation() {
try {
endOperationImpl();
}
finally {
w.???.setCursor(null);
}
} // end …
Run Code Online (Sandbox Code Playgroud) 所以我正在创建一个图像以放置在标题区域中。一切正常,除了只显示 1/4 的图像?
我的图像实际上是文本和图像组合在一个图像中 EX: JKTeater [ ] <-- 图标,所以现在只有 JKT 显示在标题区域中
这是 create() 方法
public void create() {
super.create();
setTitle("JKTeater Application");
setMessage("Hello World");
if (image != null) setTitleImage(image);
}
Run Code Online (Sandbox Code Playgroud)
编辑
我确信您是否真的可以将背景颜色从基本颜色更改为渐变颜色会要求很高
所以现在我要完成完成Bugzilla安装的最后步骤.我一直得到'disabledtext'不能有默认值.
这是完整的错误.
*初始化"依赖树更改"email_setting ...在表格配置文件中更新列disabledtext ...旧:mediumtext DEFAULT''NOT NULL新:mediatext NOT NULL
DBD :: mysql :: db失败:BLOB/TEXT列'disabledtext'在Bugzilla/DB.pm第729行没有默认值[for Statement"ALTER TABLE profiles ALTER COLUMN disabledtext DROP DEFAULT"].
Bugzilla :: DB :: bz_alter_column_raw('Bugzilla :: DB :: Mysql = HASH(0x6e8f7f0)','profiles','disabledtext','HASH(0xa0a73d0)','HASH(0xa0be4a8)',undef)在Bugzilla调用/DB.pm第688行
Bugzilla :: DB :: bz_alter_column('Bugzilla :: DB :: Mysql = HASH(0x6e8f7f0)','profiles','disabledtext','HASH(0xa0a73d0)')在Bugzilla/Install/DB.pm第505行调用
在./checksetup.pl第199行调用的Bugzilla :: Install :: DB :: update_table_definitions('HASH(0x30d53d0)')
Bugzilla/Install/DB.pm中的实际错误是什么?
这个东西很新,所以任何都会很棒.
Bugzilla = 4.2.5 Mysql = 5.6.11 OS = Suse 12
我正在尝试从表格中的数据创建一个arraylist.我需要从可见列中获取值,但我还需要从表中不可见的列中获取值.使用SWT和Table Viewer,我不知道如何不在表格中显示列.我也不知道如何通过指定列名来从表中提取数据.
我一直使用Swing,所以我一直使用Table Model Class.在swing中,创建列,隐藏它们并从中获取数据非常简单.
这就是我在以前的Swing项目中完成它的方法.
在我的表模型类中:
public String getColumnName(int column) {
String s = null;
switch (column) {
case ITEMID_COL: {
s = "ItemId";
break;
}
Run Code Online (Sandbox Code Playgroud)
那么 getValueAt()
public Object getValueAt(int row, int column) {
Object o = null;
try {
switch (column) {
case ITEMID_COL: {
o = rds.get(row).rev.getItem().getStringProperty("item_id");
break;
}
Run Code Online (Sandbox Code Playgroud)
因此,当我需要其他课程中的表格中的数据时,我所要做的就是
Object item_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().ITEMID_COL);
Run Code Online (Sandbox Code Playgroud)
我也可以通过设置来轻松隐藏列MAX_COLUMNS
.
问题:
我需要学习如何向表中添加不会显示但仍使用表查看器包含值的列.
我需要学习如何从表中访问值,因此我可以从列中创建可见和不可见数据的数组.
这甚至可以使用表格查看器吗?
当用户使用窗口关闭按钮(红色X)按钮关闭任何应用程序窗口时.它会导致我的应用程序出现Widget is Disposed问题.当他们使用我提供的关闭应用程序关闭窗口时.一切正常.
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, "Close Aplot", true);
}
@Override
protected void okPressed() {
getShell().setVisible(false);
}
Run Code Online (Sandbox Code Playgroud)
我有一个方法来创建2个按钮.这些按钮与"确定","关闭"按钮不同.单击时,它们将执行不同的操作.我希望2个按钮并排放在我的基础复合材料的顶部.哪个使用GridLayout.我希望能够将按钮并排放置.
这是我添加方法的createDialogArea.
protected Control createDialogArea(Composite parent) {
final Composite area = new Composite(parent, SWT.NONE);
final GridLayout gridLayout = new GridLayout();
gridLayout.marginWidth = 15;
gridLayout.marginHeight = 10;
area.setLayout(gridLayout);
createTopButtons(area);
createTableViewer(area);
return area;
}
Run Code Online (Sandbox Code Playgroud)
这是按钮方法.
protected void createTopButtons(Composite parent) {
Button pdfButton = new Button(parent, SWT.PUSH);
pdfButton.setText("Create PDF");
pdfButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
close();
}
});
Button plotButton = new Button(parent, SWT.PUSH);
plotButton.setText("Plot");
plotButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
close();
}
});
}
Run Code Online (Sandbox Code Playgroud)
我需要将Gridlayout添加到createTopButtons吗?
如果是这样的话,我怎么能并排得到它们而不是另一个呢?
同样在createDialogArea中,我可以使用gridLayout安排我的组件吗?
示例 …
如何将组合框添加到表格中的特定列?
我希望我的最后一个专栏有一个包含3个选项的组合框(是,否,两者).我将包含我的表格代码,这样您就可以更好地告诉我新代码是如何进行的.
//////////////////////////////////////////////////////////////////////////
// createTableViewer() //
//////////////////////////////////////////////////////////////////////////
private TableViewer createTableViewer(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
createColumns(parent, viewer);
Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
// Layout the viewer
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setInput(AplotDataModel.getInstance().getArrayData());
viewer.getControl().setLayoutData(gridData);
return viewer;
}
//////////////////////////////////////////////////////////////////////////
// createColumns() //
//////////////////////////////////////////////////////////////////////////
private void createColumns(final Composite parent, final TableViewer viewer) {
String[] titles = { "ItemId", "RevId", "PRL", "Dataset Name", "EC Markup" };
int[] bounds …
Run Code Online (Sandbox Code Playgroud)