I have a question concerning ctabfolders in eclipse rcp.
I created an e4 RCP app with a window comprising a stack part container, which contains a stack.
this stack contains 1 part. in this part, there is a ctabfolder and one ctabitem.
when I launch the app via the product file, I see this:
there are 2 problems:
1. the partCTabFolder appears at the top of the window, and I would like to remove it.
2. the test1 CTabItem is not selected; I disabled the flag "simple" with setSimple(false), so the CTabItem should be displayed with rounded borders, which is not the case until I click on it.
in this case, the window appears like this:
the problem 1 remains, but the 2nd one is resolved.
I know that part classes are created lazily, but I think it does not apply here since the part is the only one and is displayed as soon as the window is run.
here is the code of the #PostConstruct method:
#PostConstruct
public void postConstruct(Composite parent) {
parent.setLayout(new FillLayout(SWT.HORIZONTAL));
CTabFolder tabFolder = new CTabFolder(parent, SWT.BORDER);
tabFolder.setSimple(false);
tabFolder.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
CTabItem tbtmTest = new CTabItem(tabFolder, SWT.NONE);
tbtmTest.setText("test1");
Composite composite = new Composite(tabFolder, SWT.NONE);
tbtmTest.setControl(composite);
composite.setLayout(new GridLayout(2, false));
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
new Label(composite, SWT.NONE);
Label lblHelloWolf = new Label(composite, SWT.NONE);
lblHelloWolf.setText("Hello World!");
}
is it possible to get rounded CTabItem borders as soon as the part is displayed?
How to get rid of the "partCTabFolder" text at the top of the window?
thank you
The "partCTabFolder" tab is because you have put your part in a 'Part Stack' - the part stack uses tabs for each part. If you don't want this just put your Part directly in the main window or a Part Sash Container.
CTabFolder only draws the full curved tab for the selected part. Other tabs just have to slightly rounded outline. You can make your tab the selected tab initially by calling:
tabFolder.setSelection(tbtmTest);
Related
I'm working in a GUI Java Application in Eclipse IDE. I'm using Window Builder to speed the UI design.
As a part of refactoring, I've changed the sequential and repetitive code to encapsulated versions in other packages, this breaks the "Design" view, but does not affect the application itself.
The problem is that any change made to the ui needs to be seen through the compiled app, (after compile and run the app I mean), and I need to manually relaunch app any time I make a change.
So, my question is:
Is there any plugin or tool that detects changes and automatically relaunches the application, as nodemon does in Nodejs applications.
Thanks in advance.
There is no such tool AFAIK. The next thing is to place the program in Debug mode add a refresh button to redraw the widget and hope for the best (the JVM might or might not be able to re-initialize your class).
Alternatively, you can create a class that monitors the filesystem for recompiles and then restarts your application.
All bleh...
The best tip I can give you is to redesign your application in a way that Windowbuilder can understand.
I assume you have refactored your UI into multiple modular parts. If your UI consists of e.g. a Customer Detail panel and a Customer List panel, you might want to develop each of these separately. This is something WB can handle fine.
Create your modular UI classes in such a way that WB can understand them by subclassing a Widget (preferably Composite). The class below can be added to the palette of Windowbuilder and dragged into your 'composite' application.
public class MyCustomerDetail extends Composite {
public MyCustomerDetail(Composite pParent, int pStyle) {
super(pParent, pStyle);
GridLayout gridLayout = new GridLayout(2, false);
setLayout(gridLayout);
Label label = new Label(this, SWT.NONE);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
label.setText("Customer Name");
Text name = new Text(this, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
name.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
}
}
Don't make a POJO class with a GUI method. The following class cannot be handled by WB and is of bad taste altogether.
public class MyCustomerDetail {
public void createUI(Composite pParent) {
Label label = new Label(pParent, SWT.NONE);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
label.setText("Customer Name");
Text name = new Text(pParent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
name.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
}
}
I'm stuck with this Codename one UI component for two days and still couldn't get a proper solution...I added tabs in my application but when I run the application, the tabs I added don't look as I expected.
The height of my tab is too big and I want to reduce it.
See the screenshot of how the tab currently looks below:
And here is the code I'm using in my application:
Tabs t = new Tabs();
Style s = UIManager.getInstance().getComponentStyle("Tab");
FontImage icon1 = FontImage.createMaterial(FontImage.MATERIAL_QUESTION_ANSWER, s);
Container container1 = BoxLayout.encloseY();
Container container2 = BoxLayout.encloseY();
t.addTab("Tab1", icon1, container1);
t.addTab("Tab2", container2);
hi.add(BorderLayout.SOUTH, t);
hi.show();
Open your GUI Builder and style the Tab Uiid to reduce the padding as necessary:
Style the Unselected, Selected and Pressed to have the same padding size, see the image below to know the key elements to touch:
I want to add an image and a label in a group on a composite by using eclipse 4 RCP. Example image is like below. How can I do this?
My example code is below:
Group group_incom = new Group(dynamicDataComp, SWT.NONE);
group_incom.setLayout(new GridLayout(2,true));
group_incom.setText("Incom. Msg.");
Label lbl_incomMsg = toolkit.createLabel(group_incom, "# of Incoming Messages : ", SWT.NONE);
Image img = new Image(lbl_incomMsg.getDisplay(), "<path>");
lbl_incomMsg.setImage(img);
lbl_incomMsg.setLocation(15, 15);
lbl_incomMsg.pack();
The problem is, I can see the image but I can not see the label text.
Label can display text or an image, it won't display both. So either use two Label controls one for the image and one for the text or use CLabel which can display both.
I have written an Eclipse plugin which provides some UI which uses the CTabFolder component.
The CTabItems provided by Eclipse have a blue border when active and a white border when inactive (grey if the CTabItem is an Eclipse View).
The CTabItems which I have created are always bordered in white and the text on the active tab is underlined.
How can I control the style of my CTabItems to more closely match the Eclipse tabs?
EDIT:
I have come up with the following code which extracts the correct colors from the active Eclipse theme.
IWorkbench workBench = PlatformUI.getWorkbench();
ITheme theme = workBench.getThemeManager().getCurrentTheme();
ColorRegistry colreg = theme.getColorRegistry();
Color c1 = colreg.get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START);
Color c2 = colreg.get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END);
However, this isn't ideal as IWorkbenchThemeConstants is within an eclipse ui internal package.
Is there an alternative public way to reference the same colors referred to by these internal IWorkbenchThemeConstants?
You can use methods for defining gradient on selected and non-selected CTabFolder items. For example
CTabFolder folder = new CTabFolder(shell, SWT.BORDER);
folder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_YELLOW), display.getSystemColor(SWT.COLOR_RED)}, new int[]{100}, true);
folder.setSelectionBackground(new Color[]{display.getSystemColor(SWT.COLOR_WHITE), display.getSystemColor(SWT.COLOR_BLUE)}, new int[]{100}, true);
will produces this (ugly) tabs
So you just have to hit right colors which eclipse have..
Or you could write your own CTabFolderRenderer and set it to your CTabFolder instance.
EDIT
For Eclipse colors try
folder.setSelectionBackground(new Color[]{new Color(display, new RGB(242, 244, 247)), new Color(display, new RGB(157, 167, 195))}, new int[]{100}, true);
EDIT
Found the way how to do it correctly
folder.setSelectionBackground(new Color[]{display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT), display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND)}, new int[]{100}, true);
I'm having trouble embedding Swing components inside SWT (such as eclipse plugin..)
Currently what I have:
public void createPartControl(Composite parent) {
java.awt.Frame f = SWT_AWT.new_Frame(parent);
JPanel panel = new JPanel(new BorderLayout());
JButton button = new JButton("Swing button");
JLabel label = new JLabel("Swing label");
panel.add(label,BorderLayout.NORTH);
panel.add(button,BorderLayout.CENTER);
f.add(panel);
}
This code snippet fails to load, the plugin crashes on the first line...
Any idea how to incorporate these components?
Thanks!
http://www.eclipse.org/articles/article.php?file=Article-Swing-SWT-Integration/index.html
Minimally, embedding an AWT frame inside an SWT composite is just two simple lines of code
Composite composite = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND);
Frame frame = SWT_AWT.new_Frame(composite);
Since your code is failing at the first line then please first make sure that the parent Composite is created using SWT.EMBEDDED. If it is not then create a child composite using the SWT.EMBEDDED and then call
java.awt.Frame f = SWT_AWT.new_Frame(newChildComposite);
An instance of
org.eclipse.swt.Composite is created
with the SWT.EMBEDDED style. This
style signals that an AWT frame is to
be embedded inside the Composite. The
call to the static new_Frame method
creates and returns such a frame. The
frame may then be populated with AWT
and/or Swing components.
Taken from Article-Swing-SWT-Integration