I'm learning how to use Eclipse Scout and started with the tutorials found at
Eclipse Scout Tutorials
I've proudly completed the first hello world tutorial and got stuck while trying to complete the Minicrm Tutorial
Everything went well until this step, when I needed to restart the server and any of the GUI clients to see that the table in the outline I just created is not well formatted. The problem: None of the clients show me the created table, they are all empty.
I ticked the visible field in every newly added column (all but the primary key column) and I don't see why no table is shown. I even tried to go on with the tutorial and setting the column width to 200 as desired, but still no table. I pasted the code for the Class CompanyTablePage below. A screenshot of the Scout Explorer is also provided. I really just started with Eclipse Scout and would appreciate any help or hints!
Thanks,
Isa
/**
*
*/
package org.eclipsescout.demo.minicrm.client;
import org.eclipse.scout.commons.annotations.Order;
import org.eclipse.scout.commons.annotations.PageData;
import org.eclipse.scout.rt.client.ui.basic.table.columns.AbstractLongColumn;
import org.eclipse.scout.rt.client.ui.basic.table.columns.AbstractStringColumn;
import org.eclipse.scout.rt.client.ui.desktop.outline.pages.AbstractPageWithTable;
import org.eclipse.scout.rt.extension.client.ui.basic.table.AbstractExtensibleTable;
import org.eclipse.scout.rt.shared.TEXTS;
import org.eclipsescout.demo.minicrm.client.CompanyTablePage.Table;
import org.eclipsescout.demo.minicrm.shared.CompanyTablePageData;
import org.eclipsescout.demo.minicrm.client.CompanyTablePage.Table.NameColumn;
/**
* #author Isa
*/
#PageData(CompanyTablePageData.class)
public class CompanyTablePage extends AbstractPageWithTable<Table> {
#Override
protected String getConfiguredTitle() {
return TEXTS.get("Company");
}
#Order(10.0)
public class Table extends AbstractExtensibleTable {
/**
* #return the ShortNameColumn
*/
public ShortNameColumn getShortNameColumn() {
return getColumnSet().getColumnByClass(ShortNameColumn.class);
}
/**
* #return the NameColumn
*/
public NameColumn getNameColumn() {
return getColumnSet().getColumnByClass(NameColumn.class);
}
/**
* #return the CompanyNrColumn
*/
public CompanyNrColumn getCompanyNrColumn() {
return getColumnSet().getColumnByClass(CompanyNrColumn.class);
}
#Order(10.0)
public class CompanyNrColumn extends AbstractLongColumn {
#Override
protected boolean getConfiguredDisplayable() {
return false;
}
#Override
protected boolean getConfiguredPrimaryKey() {
return true;
}
#Override
protected boolean getConfiguredVisible() {
return false;
}
}
#Order(20.0)
public class ShortNameColumn extends AbstractStringColumn {
#Override
protected String getConfiguredHeaderText() {
return TEXTS.get("ShortName");
}
#Override
protected int getConfiguredWidth() {
return 200;
}
}
#Order(30.0)
public class NameColumn extends AbstractStringColumn {
#Override
protected String getConfiguredHeaderText() {
return TEXTS.get("Name");
}
#Override
protected int getConfiguredWidth() {
return 200;
}
}
}
}
it seems to me that you selected the wrong template when you created your Scout project.
Are you sure you choose "Outline based application" ?
The different types are described here: type of application.
The main difference is located in Desktop#execOpened() of your scout application. You will need to change this implementation by hand.
Depending on the chosen template, the SDK add some default elements (a Form, an Outline...) during the project creation. You can add these elements after the project creation.
Related
I am new to using Realm library and was trying to implement it in my android application. Just got stuck at a point where I am trying to section my listview based on the view type of a particular element in my json response.
I have tried to implement the sections with recycler view but the problem is I have 2 view types and addition of headers for those view types was causing an issue. Since Realm doesn't have the support of RecyclerAdapter, I created an implementation that will use a custom adapter that supports the RecyclerView.
So, I though I will use a ListView and try to use a simple interface for each of the Object type to determine the type and then insert the Headers based on the position of the group.
For some reason Realm is not allowing me to implement an interface in a class which extends RealmObject.
This is how that class looks like :
import com.google.gson.annotations.SerializedName;
import io.realm.RealmObject;
import io.realm.annotations.Ignore;
import io.realm.annotations.PrimaryKey;
public class TestClass extends RealmObject implements Subjects {
#PrimaryKey
#SerializedName("subjectID")
private String subjectID;
private String subjectDate;
#SerializedName("subjectDescription")
private String subjectDescription;
public String getSubjectID() {
return subjectID;
}
public void setSubjectID(String subjectID) {
this.subjectID = subjectID;
}
public String getSubjectDate() {
return subjectDate;
}
public void setSubjectDate(String subjectDate) {
this.subjectDate = subjectDate;
}
public String getSubjectDescription() {
return subjectDescription;
}
public void setSubjectDescription(String subjectDescription) {
this.subjectDescription = subjectDescription;
}
#Override
public boolean isSubjectA() {
return true;
}
#Override
public boolean isFoo() {
return false;
}
#Override
public boolean isBar() {
return false;
}
}
And this is the Compilation Error log :
Error:(76, 20) error: Getter isSubject is not associated to any field.
Note: Creating DefaultRealmModule
Warning:File for type 'io.realm.DefaultRealmModule' created in the last round will not be subject to annotation processing.
Warning:File for type 'io.realm.DefaultRealmModuleMediator' created in the last round will not be subject to annotation processing.
2 warnings
I have no idea why is complaining about this issue but its not compiling the project.
I read a few discussion about the issue here : link .. Apparently, there's an open discussion about this issue but any other help will be really appreciated.. Thank you
You have an typo in your field's name, also it shouldn't have prefix, so it would be "subject", and getter must be isSubject()
#Ignore
private boolean subject = false;
public boolean isSubject() {
return subject;
}
.
I need to produce two separate jar files, both interact with each other but do different things. I have two projects loaded into Eclipse, but both use a lot of the same imports, and so I have them in subfolders under the same workspace.
One of them gets "java class xxxxcould not be found" when I try to run it.
As I attempted to fix that, I was comparing the two projects and noticed that a folder was part of the external build path of the working one, but not the non-working one. I added it to the non-working one and broke the working one.
The one that had been working now has an error on the main class name. I call the program ZSTATEngine, and so the class is
public class ZSTATEngine implements ETOSFilterEngine
Now that name is highlighted and when I mouse over it is says:"the type ZSTATEngine must implement the inherited abstract method ETOSFilterEngine.doFilter(MessageBlock)"
What could have changed? It was working fine before, and nothing in the code itself changed. I don't understand how the referenced libraries work, but it at least appears nothing changed in their structure in the formerly-working project.
Ok some further information: I do actually have a section within that class:
public MessageBlock doFilter(MessageBlock msgBlock)
so I am implementing that method... but that method has an error inside of it now,
"The method addFilteredMessage(MessageBlock) in the type FilterFramework is not applicable or the arguments (MessageBlock) ...
How could that have gone bad? It was working fine too.
Here's the full code:
package com.ibm.tpf.internal;
import java.awt.Color;
/*import java.util.ArrayList;*/
/*import java.util.*;*/
import com.ibm.tpf.etos.TPFFilter.*;
//import com.ibm.tpf.etos.TPFFilter.TernarySwitch;
import com.ibm.tpf.etos.api.*;
/*
import com.ibm.tpf.etos.api.Constants;
import com.ibm.tpf.etos.api.MessageBlock;
*/
import com.ibm.tpf.etos.filter.*;
/*
import com.ibm.tpf.etos.filter.ETOSFilterEngine;
import com.ibm.tpf.etos.filter.FilterConfigurationException;
import com.ibm.tpf.etos.filter.FilterFramework;
import com.ibm.tpf.etos.filter.FilterRuntimeException;
*/
public class ZSTATEngine implements ETOSFilterEngine {
FilterFramework fw = null;
String[] names = null;
public ZSTATEngine(FilterFramework filFW, String[] parms) {
super();
this.fw = filFW;
}
/* AAES0009I 13.45.01 FROM TA 05 : AUTC0000I TOSFCOLOR_GREEN TOSBCOLOR_NONE TOSHOLD_0 TOSSAVE_0 TOSALERT_0 AUTC1111I 12.04.41 OK */
public MessageBlock doFilter(MessageBlock msgBlock) throws FilterRuntimeException {
if(msgBlock.getMsgID().equals("AAES0009I")) { /* only handle messages that start with AAES0009I */
if(msgBlock.getMsg().indexOf("ZUVRT") != -1) { /* if the message contains "ZUVRT" then let it through. We want to react to the result of it, not the ZUVRT itself. */
return msgBlock;
}
if(msgBlock.getMsg().indexOf("AUTC0000I") != -1) { /* search string to see if "AUTC0000I is in it. If it is then do..." */
String myString = msgBlock.getMsg();
Color fColor = Color.WHITE; /* set default colors */
Color bColor = Color.BLACK;
msgBlock.setSuppressed(TernarySwitch.ON); /* suppress original message to display new one */
String[] myStringParts = myString.split("\\s+",13); /* divide message into 13 parts. The 13th part is everything remaining. */
String finalPart = myStringParts[12].toString(); /* print last part to the screen */
MessageBlock mb = new MessageBlock(finalPart, Constants.ETOS_ONE_MSG);
String fColorMsg = myStringParts[7].toString(); /* Process the foreground color portion */
if (!fColorMsg.contains("NONE")) {
fColor = ColorStringInterpreter(fColorMsg);
mb.setForeground(fColor);
}
String bColorMsg = myStringParts[8].toString(); /* Process the background color portion */
if (!bColorMsg.contains("NONE")) {
bColor = ColorStringInterpreter(bColorMsg);
mb.setBackground(bColor);
}
String holdMsg = myStringParts[9].toString(); /* Process the hold message portion */
if (holdMsg.toUpperCase().startsWith("TOS")) { /* if it starts with TOS, grab only the number at the end */
String[] holdPart = holdMsg.split("_",2);
if (holdPart[1].toString().equals("1")) {
mb.setHeld(TernarySwitch.ON);
}
}
else {
if (holdMsg.equals("1")) { /* otherwise, just use the number */
mb.setHeld(TernarySwitch.ON);
}
}
String saveMsg = myStringParts[10].toString(); /* Process the save areas. These have two formats currently: TOSSAVE_X_X_X_X and BBBBBBBBB, where X is a digit 1-32, and B is binary. */
if (saveMsg.toUpperCase().startsWith("TOS")) {
String[] savePart = saveMsg.split("_"); /* handle the multiple digit save areas, and ignore the first split which is TOSSAVE */
if (!savePart[1].toString().equals("0")) {
long areaBits = 0;
for (int i=1; i<savePart.length; i++) {
areaBits |= 1L << Integer.parseInt(savePart[i]);
}
mb.setSave(areaBits);
}
}
else { /* otherwise, just use the binary string directly */
long areaBits = Long.parseLong(myStringParts[10].toString(), 2);
mb.setSave(areaBits);
}
fw.addFilteredMessage(mb); /* this is the command that pieces the whole message together */
}
}
int plusLocation = msgBlock.getMsg().lastIndexOf('+');
if (plusLocation > 0) {
MessageBlock mb1 = new MessageBlock(msgBlock.getMsg(), msgBlock.getFlag());
fw.addFilteredMessage(mb1);
msgBlock.setSuppressed(TernarySwitch.ON);
MessageBlock mb2 = new MessageBlock("", Constants.ETOS_ONE_MSG);
fw.addFilteredMessage(mb2);
}
return msgBlock; /* whatever gets returned is what the system prints */
}
private Color ColorStringInterpreter(String colorMsg) throws FilterRuntimeException {
if (colorMsg.toUpperCase().startsWith("TOS")) { /* if it starts with TOS, then we're using color names */
String[] colorParts = colorMsg.split("_",2);
String colorTxt = colorParts[1].toString().trim();
if (colorTxt.toUpperCase() != "NONE") {
Color finalColor = Colors.fromString(colorTxt);
return finalColor;
}
}
else {
String[] colorParts = colorMsg.split("_",3); /* otherwise we're using RGB values */
String sRed = colorParts[0].toString().trim();
String sGreen = colorParts[1].toString().trim();
String sBlue = colorParts[2].toString().trim();
/*mb = new MessageBlock(sRed, Constants.ETOS_ONE_MSG);*/
int iRed = Integer.parseInt(sRed);
int iGreen = Integer.parseInt(sGreen);
int iBlue = Integer.parseInt(sBlue);
Color finalColor = new Color (iRed, iGreen, iBlue);
return finalColor;
}
return null;
}
public String getName() {
return null;
}
public void modifyState(Object[] newParams) throws FilterConfigurationException, FilterRuntimeException {
}
public boolean isActive() {
return false;
}
public void shutdown() {
}
}
public class ZSTATEngine implements ETOSFilterEngine
According to above code, your class ZSTATEngine is implementing an interface ETOSFilterEngine, which means your class need to implement all the abstract methods of ETOSFilterEngine.
From Java doc:
Interfaces form a contract between the class and the outside world,
and this contract is enforced at build time by the compiler. If your
class claims to implement an interface, all methods defined by that
interface must appear in its source code before the class will
successfully compile.
Check the link: http://www-01.ibm.com/support/knowledgecenter/SSB23S_1.1.0.9/com.ibm.tpfops.doc_1112/aaeo1/fengapi.html?cp=SSB23S_1.1.0.9%2F2-3-10-3
Below are the 5 methods that are present in ETOSFilterEngine, which you need to implement.
public MessageBlock doFilter (MessageBlock) throws
FilterRuntimeException;
public void modifyState (Object[ ]) throws
FilterConfigurationException,
FilterRuntimeException;
public boolean isActive();
public void shutdown();
public String getName();
Above link has a code example on how to properly implement this interface. You can see that the class ZSTATEngine in the example is implementing all the 5 methods provided by ETOSFilterEngine.
Check the type of MessageBlock in your imports, it should be import
com.ibm.tpf.etos.api.MessageBlock; I can see that you have commented your import which is wrong.
Uncomment the line : import com.ibm.tpf.etos.api.MessageBlock;
AS mentioned by "Jakub Zaverka" perhaps you have two versions in classpath or build path. Check the jar order, whether is picking the right class... It will happen even if no code has changed.
One way to find it out is, just do an F3 on ETOSFilterEngine and click "Link with editor" option in package explorer. It will show the .class file and the jar from which its picked up.. If its from the wrong jar or old jar, just go to Project>Properties>Build Path>Order and Export and change the order of the right jar to the top, by clicking on Top button..
As per the startup instructions I was able to successfully generate table classes in JOOQ that end up looking like so:
public class AgencyMeta extends TableImpl<AgencyMetaRecord> {
private static final long serialVersionUID = 214852552;
/**
* The reference instance of <code>PUBLIC.AGENCY_META</code>
*/
public static final AgencyMeta AGENCY_META = new AgencyMeta();
/**
* The class holding records for this type
*/
#Override
public Class<AgencyMetaRecord> getRecordType() {
return AgencyMetaRecord.class;
}
/**
* The column <code>PUBLIC.AGENCY_META.ID</code>.
*/
public final TableField<AgencyMetaRecord, Long> ID = createField("ID", org.jooq.impl.SQLDataType.BIGINT.nullable(false).defaulted(true), this, "");
/**
* The column <code>PUBLIC.AGENCY_META.AGENCY_ID</code>.
*/
public final TableField<AgencyMetaRecord, Long> AGENCY_ID = createField("AGENCY_ID", org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "");
/**
* The column <code>PUBLIC.AGENCY_META.KEY</code>.
*/
public final TableField<AgencyMetaRecord, String> KEY = createField("KEY", org.jooq.impl.SQLDataType.VARCHAR.length(255).nullable(false), this, "");
/**
* The column <code>PUBLIC.AGENCY_META.VALUE</code>.
*/
public final TableField<AgencyMetaRecord, String> VALUE = createField("VALUE", org.jooq.impl.SQLDataType.CLOB, this, "");
/**
* Create a <code>PUBLIC.AGENCY_META</code> table reference
*/
public AgencyMeta() {
this("AGENCY_META", null);
}
/**
* Create an aliased <code>PUBLIC.AGENCY_META</code> table reference
*/
public AgencyMeta(String alias) {
this(alias, AGENCY_META);
}
private AgencyMeta(String alias, Table<AgencyMetaRecord> aliased) {
this(alias, aliased, null);
}
private AgencyMeta(String alias, Table<AgencyMetaRecord> aliased, Field<?>[] parameters) {
super(alias, Public.PUBLIC, aliased, parameters, "");
}
/**
* {#inheritDoc}
*/
#Override
public Identity<AgencyMetaRecord, Long> getIdentity() {
return Keys.IDENTITY_AGENCY_META;
}
/**
* {#inheritDoc}
*/
#Override
public UniqueKey<AgencyMetaRecord> getPrimaryKey() {
return Keys.CONSTRAINT_A0;
}
/**
* {#inheritDoc}
*/
#Override
public List<UniqueKey<AgencyMetaRecord>> getKeys() {
return Arrays.<UniqueKey<AgencyMetaRecord>>asList(Keys.CONSTRAINT_A0, Keys.CONSTRAINT_A0F);
}
/**
* {#inheritDoc}
*/
#Override
public List<ForeignKey<AgencyMetaRecord, ?>> getReferences() {
return Arrays.<ForeignKey<AgencyMetaRecord, ?>>asList(Keys.CONSTRAINT_A0FC);
}
/**
* {#inheritDoc}
*/
#Override
public AgencyMeta as(String alias) {
return new AgencyMeta(alias, this);
}
/**
* Rename this table
*/
public AgencyMeta rename(String name) {
return new AgencyMeta(name, null);
}
}
Apparently it has all the ingredients to create a table, and in part I can do so like this:
create.createTable(PRODUCT).column(PRODUCT.ID, SQLDataType.BIGINT.nullable(false).defaulted(true)).execute();
And so forth...
When the program starts up for the first time, I would like to build the h2 database on the spot.
Is there a way to create a table or even the whole database in a one-shot command? It would seem there should be based on what is provided.
As far as i know, there is only posibility to issue DDL commands manually, as described in documentation: ddl statements
The documentation describes that:
jOOQ's DDL support is currently still very limited. In the long run, jOOQ will support the most important statement types for frequent informal database migrations, though. Note that jOOQ will not aim to replace existing database migration frameworks. At Data Geekery, we usually recommend using Flyway for migrations. See also the tutorial about using jOOQ with Flyway for more information.
I've got a toolbar item with its own icon, defined in the plugin.xml file like:
<action
class="MyActionClass"
id="MyActionID"
label="MyActionLabel"
menubarPath="MyActionMenuBarPath"
toolbarPath="MyActionToolBarPath"
icon="icon/myicon.png" <---- this one
...
</action>
How do I change this dynamically when needed? I mean changing it from code
Use org.eclipse.ui.menus extension point instead and add menuContribution with dynamic. The class of dynamic should subclass ControlContribution and implement createControl method to create a button.
You should implements IElementUpdater in your Handler class.
Please refer to : https://stackoverflow.com/a/23742598/2893073
Handler class
import java.util.Map;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.menus.UIElement;
import com.packpub.e4.menu.Activator;
public class SampleHandler2 extends
AbstractHandler implements IElementUpdater{
private static ImageDescriptor image_enable =
Activator.getImageDescriptor("icons/btn_adapt_enable.png");
private static ImageDescriptor image_disable =
Activator.getImageDescriptor("icons/btn_adapt_disable.png");
/**
* The constructor.
*/
public SampleHandler2() {
}
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
//...
return null;
}
#Override
public void updateElement(UIElement element, #SuppressWarnings("rawtypes") Map map) {
boolean condition = false;
//...
if( condition ) {
element.setIcon(image_disable);
}else{
element.setIcon(image_enable);
}
}
}
invoke this Handler using ICommandService:
IWorkbenchWindow window = part.getSite().getWorkbenchWindow();
ICommandService commandService = (ICommandService) window.getService(ICommandService.class);
if (commandService != null) {
commandService.refreshElements("com.packpub.e4.menu.commands.sampleCommand", null);
}
Thanks.
I am using BlazeDS to communicate between Java and Flash/Flex. And everything works fine, except that Java Null Integer becomes 0 on Flex side.
To handle the problem with transferring a Java Null Integer to an Flash/Flex int, I have implement a custom serialization, which works on the Java side and uses negative values to express Null values.
After implementing that I get an
RangeError: Error #2006: Der angegebene Index liegt außerhalb des zulässigen Bereichs.
(in english: the index is out of range)
at ObjectInput/readObject()
at mx.collections::ArrayList/readExternal()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:586]
at mx.collections::ArrayCollection/readExternal()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayCollection.as:147]
at ObjectInput/readObject()
at mx.messaging.messages::AbstractMessage/readExternal()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\messages\AbstractMessage.as:486]
at mx.messaging.messages::AsyncMessage/readExternal()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\messages\AsyncMessage.as:170]
at mx.messaging.messages::AcknowledgeMessage/readExternal()[E:\dev\4.x\frameworks\projects\rpc\src\mx\messaging\messages\AcknowledgeMessage.as:95]
The exception occures on the Flex side while deserializing the Java Result.
Which is an list of complex objects which contains this special class with the custom serialization. Because there was no such problem until I added the custom serialization, I guess it must belong to the problem, but i have no clue what triggers the exception.
This is the code of the object with the custom serialization:
package crux.domain.dto;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
public class NullAbleID implements Serializable, Externalizable {
private static final long serialVersionUID = 788620879056753289L;
private Integer id;
public NullAbleID() {
super();
this.id = null;
}
public NullAbleID(final Integer id) {
this.id = id;
}
getter, setter for ID and hashCode and equals
#Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(this.nullToNegative(this.id));
}
#Override
public void readExternal(ObjectInput in) throws IOException {
this.id = this.negativeToNull(in.readInt());
}
private int nullToNegative(Integer id) {
if (id == null) {
return -1;
} else {
return id.intValue();
}
}
private Integer negativeToNull(int flashId) {
if (flashId < 0) {
return null;
} else {
return Integer.valueOf(flashId);
}
}
}
Flex: two classes, because we use Gas3 Granite Data Service code generation:
/**
* Generated by Gas3 v2.1.0 (Granite Data Services).
*
*/
package crux.domain.dto {
import flash.utils.IExternalizable;
[Bindable]
public class NullAbleIDBase {
public function NullAbleIDBase() {}
private var _id:Number;
public function set id(value:Number):void {
_id = value;
}
public function get id():Number {
return _id;
}
}
}
Flex sub class with read and write external
package crux.domain.dto {
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
import flash.utils.IExternalizable;
[Bindable]
[RemoteClass(alias="crux.domain.dto.NullAbleID")]
public class NullAbleID extends NullAbleIDBase implements IExternalizable{
public function readExternal(input:IDataInput):void {
id = input.readInt();
}
public function writeExternal(output:IDataOutput):void {
output.writeInt(id);
}
}
}
I have spend several hours on this problem, but I have no idea what the problem is.
Do you see the cause for the exception?
Not sure it's the cause of the problem, because I don't know BlazeDS, but the methods readExternal and writeExternal of your NullAbleID class are not symetric : you write an object of type Integer in writeExternal, and you read an int in readExternal.