I have a table with quantity and price columns that are editable and not disabled. The table is populated with ObservableList<Collection> . Collection object has a boolean attribute paid. What i am tring to achieve is whenever paid is true, make both price and quantity tablecells disabled and not editable.
This is what i have done so far:
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import javafx.application.Application;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.FloatProperty;
import javafx.beans.property.ReadOnlyFloatProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import javafx.util.Callback;
import javafx.util.converter.FloatStringConverter;
public class CollectionTable extends Application{
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) throws Exception {
TableView<Collection> tv = new TableView();
tv.setEditable(true);
TableColumn<Collection, Number> colQty = createQuantityColumn();
colQty.setCellFactory(
new Callback<TableColumn<Collection, Number>, TableCell<Collection, Number>>() {
#Override
public TableCell<Collection, Number> call(TableColumn<Collection, Number> paramTableColumn) {
return new TextFieldTableCell<Collection, Number>() {
#Override
public void updateItem(Number s, boolean b) {
super.updateItem(s, b);
TableRow row = getTableRow();
if (row != null) {
Collection item = (Collection) row.getItem();
//Test for disable condition
if (item != null && item.isPaid()) {
setDisable(true);
setEditable(false);
this.setStyle("-fx-text-fill: grey;-fx-border-color: red");
}
}
}
};
}
});
TableColumn<Collection, Number> colPrice = createPriceColumn();
colPrice.setCellFactory(
new Callback<TableColumn<Collection, Number>, TableCell<Collection, Number>>() {
#Override
public TableCell<Collection, Number> call(TableColumn<Collection, Number> paramTableColumn) {
return new TextFieldTableCell<Collection, Number>() {
#Override
public void updateItem(Number s, boolean b) {
super.updateItem(s, b);
TableRow row = getTableRow();
if (row != null) {
Collection item = (Collection) row.getItem();
//Test for disable condition
if (item != null && !item.isPaid()) {
setDisable(true);
setEditable(false);
this.setStyle("-fx-text-fill: grey;-fx-border-color: red");
}
}
}
};
}
});
TableColumn<Collection, Number> colAmount = createAmountColumn();
TableColumn<Collection, String> colMno = createMNOColumn();
tv.getColumns().addAll(colMno, colQty, colPrice, colAmount);
tv.getItems().addAll(getCollection());
Scene scene = new Scene(new BorderPane(tv), 600, 400);
primaryStage.setScene(scene);
primaryStage.show();
}
private TableColumn createQuantityColumn() {
TableColumn<Collection, Float> colQty = new TableColumn("Quantity");
colQty.setMinWidth(25);
colQty.setId("colQty");
colQty.setCellFactory(TextFieldTableCell.<Collection, Float>forTableColumn(new FloatStringConverter()));
colQty.setCellValueFactory(cellData -> cellData.getValue().quantityProperty().asObject());
colQty.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<Collection, Float>>() {
#Override
public void handle(TableColumn.CellEditEvent<Collection, Float> t) {
}
});
return colQty;
}
private TableColumn createPriceColumn() {
TableColumn<Collection, Float> colPrice = new TableColumn("Price");
colPrice.setMinWidth(25);
colPrice.setId("colPrice");
colPrice.setCellFactory(TextFieldTableCell.<Collection, Float>forTableColumn(new FloatStringConverter()));
colPrice.setCellValueFactory(cellData -> cellData.getValue().priceProperty().asObject());
colPrice.setOnEditStart(new EventHandler<TableColumn.CellEditEvent<Collection, Float>>() {
#Override
public void handle(TableColumn.CellEditEvent<Collection, Float> t) {
Collection c = ((Collection) t.getTableView().getItems().get(t.getTablePosition().getRow()));
c.setPrice(Math.abs(c.getPrice()));
}
});
colPrice.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<Collection, Float>>() {
#Override
public void handle(TableColumn.CellEditEvent<Collection, Float> t) {
Collection c = ((Collection) t.getTableView().getItems().get(t.getTablePosition().getRow()));
c.setPrice(Math.abs((float)t.getNewValue()));
//int i = collectionHandler.updateCollection(c);
}
});
return colPrice;
}
private TableColumn createAmountColumn() {
TableColumn<Collection, Float> colAmount = new TableColumn("Amount");
colAmount.setMinWidth(25);
colAmount.setId("colAmount");
colAmount.setCellValueFactory(cellData -> cellData.getValue().amountProperty().asObject());
return colAmount;
}
private TableColumn createMNOColumn() {
TableColumn colMNO = new TableColumn("M/NO");
colMNO.setMinWidth(25);
colMNO.setId("colMNO");
colMNO.setCellValueFactory(new PropertyValueFactory("mno"));
return colMNO;
}
private List<Collection> getCollection(){
List<Collection> collections = new ArrayList<>();
collections.add(new Collection(1, 10, "1", false));
collections.add(new Collection(2, 10, "12", true));
collections.add(new Collection(3, 10, "123", true));
collections.add(new Collection(4, 10, "312", true));
collections.add(new Collection(5, 10, "311", false));
collections.add(new Collection(6, 10, "322", true));
collections.add(new Collection(7, 10, "333", true));
collections.add(new Collection(8, 10, "321", false));
collections.add(new Collection(9, 10, "456", true));
collections.add(new Collection(10, 10, "551", true));
collections.add(new Collection(11, 10, "515", false));
collections.add(new Collection(12, 10, "134", true));
collections.add(new Collection(13, 10, "789", true));
collections.add(new Collection(14, 10, "879", false));
collections.add(new Collection(15, 10, "987", true));
collections.add(new Collection(16, 10, "856", true));
collections.add(new Collection(17, 10, "956", true));
collections.add(new Collection(18, 10, "589", true));
collections.add(new Collection(19, 10, "852", false));
collections.add(new Collection(20, 10, "456", false));
collections.add(new Collection(21, 10, "623", true));
collections.add(new Collection(22, 10, "147", false));
collections.add(new Collection(23, 10, "125", true));
collections.add(new Collection(24, 10, "258", false));
collections.add(new Collection(25, 10, "325", true));
collections.add(new Collection(26, 10, "753", true));
collections.add(new Collection(27, 10, "357", false));
collections.add(new Collection(28, 10, "159", false));
return collections;
}
public class Collection{
private final FloatProperty quantity = new SimpleFloatProperty();
private final FloatProperty price = new SimpleFloatProperty();
private final FloatProperty amount = new SimpleFloatProperty();
private final BooleanProperty paid = new SimpleBooleanProperty(false);
private String mno;
public Collection(){
this(0f, 0f, null, false);
}
public Collection(float quantity, float price, String mno, boolean paid) {
setQuantity(quantity);
setPrice(price);
setMno(mno);
setPaid(paid);
this.amount.bind(this.quantity.multiply(this.price));
}
public String getMno() {
return mno;
}
public void setMno(String mno) {
this.mno = mno;
}
public float getQuantity() {
return quantityProperty().get();
}
public void setQuantity(float quantity) {
quantityProperty().set(quantity);
}
public FloatProperty quantityProperty() {
return quantity ;
}
public float getPrice() {
return priceProperty().get();
}
public void setPrice(float price) {
priceProperty().set(price);
}
public FloatProperty priceProperty() {
return price ;
}
public float getAmount() {
return amountProperty().get();
}
public ReadOnlyFloatProperty amountProperty() {
return amount ;
}
public BooleanProperty paidProperty() {
return paid;
}
public void setPaid(boolean approved) {
this.paid.set(approved);
}
public boolean isPaid() {
return paid.get();
}
}
}
The problem with my code is that as i scroll down the table and up again, cells which were previously enabled and editable change to disabled and not editable.
Before scroll After scroll:
The first problem is that you don't reset the state when a cell is reused from one which is paid to one which is not paid. This will happen, among other times, when you scroll. If a cell was previously used in a row that represented a "paid" item (so it is disabled, not editable, and has a red border), and is reused for an "unpaid" item, your updateItem() method will not change the editable or disabled state (or the style). So you should have something like:
if (item != null && item.isPaid()) {
setDisable(true);
setEditable(false);
this.setStyle("-fx-text-fill: grey;-fx-border-color: red");
} else {
setDisable(false);
setEditable(true);
setStyle("");
}
The second problem is that you have no control over the order in which the cell's state is updated. It seems that sometimes the row property is updated after the updateItem() method is called, so you end up with inconsistent state. You can safely use the cell's index to get the correct item from the table's data.
Also note that since both cell factories are identical, there is no need to replicate the code. This works for me:
#Override
public void start(Stage primaryStage) throws Exception {
TableView<Collection> tv = new TableView();
tv.setEditable(true);
TableColumn<Collection, Number> colQty = createQuantityColumn();
Callback<TableColumn<Collection, Number>, TableCell<Collection, Number>> cellFactory = new Callback<TableColumn<Collection, Number>, TableCell<Collection, Number>>() {
#Override
public TableCell<Collection, Number> call(TableColumn<Collection, Number> paramTableColumn) {
return new TextFieldTableCell<Collection, Number>() {
#Override
public void updateItem(Number s, boolean b) {
super.updateItem(s, b);
if (! isEmpty()) {
Collection item = getTableView().getItems().get(getIndex());
// Test for disable condition
if (item != null && item.isPaid()) {
setDisable(true);
setEditable(false);
this.setStyle("-fx-text-fill: grey;-fx-border-color: red");
} else {
setDisable(false);
setEditable(true);
setStyle("");
}
}
}
};
}
};
colQty.setCellFactory(cellFactory);
TableColumn<Collection, Number> colPrice = createPriceColumn();
colPrice.setCellFactory(cellFactory);
TableColumn<Collection, Number> colAmount = createAmountColumn();
TableColumn<Collection, String> colMno = createMNOColumn();
tv.getColumns().addAll(colMno, colQty, colPrice, colAmount);
tv.getItems().addAll(getCollection());
Scene scene = new Scene(new BorderPane(tv), 600, 400);
primaryStage.setScene(scene);
primaryStage.show();
}
Related
When I create combo box in particular only one 3rd column using table viewer in Eclipse SWT.
I think I've done everything ok until now, however when I compile the code then i get error:
Code:
public void createPartControl(Composite parent) {
Composite tableComposite = new Composite(parent, SWT.NONE);
tableColumnLayout = new TableColumnLayout();
tableComposite.setLayout(tableColumnLayout);
tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true));
tableViewer = new TableViewer(tableComposite, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
// TODO viewer.setLabelProvider(new ViewLabelProvider());
table = tableViewer.getTable();
// Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
String[] titles = { "Threat Name", "Category Name", "Status",
"Priority", "Description", "Justification" };
int[] bounds = { 100, 100, 100, 100 };
TableViewerColumn col = createTableViewerColumn(titles[2], bounds[2], 2);
col.setLabelProvider(new ColumnLabelProvider() {
#Override
public String getText(Object element) {
Dummy p = (Dummy) element;
return p.getValue();
}
});
col.setEditingSupport(new FirstValueEditingSupport(tableViewer));
}
private SelectionAdapter getSelectionAdapter(final TableColumn column,
final int index) {
SelectionAdapter selectionAdapter = new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
tableViewer.refresh();
}
};
return selectionAdapter;
}
private static class Dummy {
public String value;
public Dummy(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
public static class FirstValueEditingSupport extends EditingSupport {
private final TableViewer viewer;
private final CellEditor editor;
private final String[] possibleValues = { "Mitigated",
"Not Applicable", "Not Started", "Needs Investigation" };
public FirstValueEditingSupport(TableViewer viewer) {
super(viewer);
this.viewer = viewer;
this.editor = new ComboBoxCellEditor(viewer.getTable(),
possibleValues);
}
#Override
protected CellEditor getCellEditor(Object element) {
return editor;
}
#Override
protected boolean canEdit(Object element) {
return true;
}
#Override
protected Object getValue(Object element) {
Dummy dummy = (Dummy) element;
int index = 0;
for (int i = 0; i < possibleValues.length; i++) {
if (Objects.equals(possibleValues[i], dummy.getValue())) {
index = i;
break;
}
}
return index;
}
#Override
protected void setValue(Object element, Object value) {
Dummy dummy = (Dummy) element;
int index = (Integer) value;
dummy.setValue(possibleValues[index]);
viewer.update(element, null);
}
}
private void fillRows(String shortdesc, String categ, String descp) {
System.out.println("fillRows call from above method.");
TableColumn status_Name_Col = tableViewer.getTable().getColumn(2);
System.out.println("**************** status_Name_Col ************ "
+ status_Name_Col);
tableViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
#Override
public void selectionChanged(
SelectionChangedEvent selectionChangedEvent) {
StructuredSelection selection = (StructuredSelection) selectionChangedEvent
.getSelection();
System.out.println(((Dummy) selection.getFirstElement())
.getValue());
}
});
List<Dummy> elements = new ArrayList<>();
for (int i = 0; i < Connection.Number_Of_Connection; i++) {
elements.add(new Dummy("First option"));
}
tableViewer.setInput(elements);
tableColumnLayout.setColumnData(status_Name_Col, new ColumnWeightData(
1, true));
tableViewerColumn.setEditingSupport(new FirstValueEditingSupport(
tableViewer));
}
Questions:
how to display combo box in particular only one column?
You must not do the TableViewer setInput call until you have set up everything on the table. All the content providers, label providers, column layouts, editing support, .... must be set before setInput is called.
You must also call setColumnData for every column you create.
From this code.makery blog, i was able to understand how tableview sorting and filtering works and implement. The problem is the blog showed an example that does not use ListProperty. When i tried to change the code example with ListProperty no sorting and filtering happens.
This is what the blog provided
FilteredList<Person> filteredData = new FilteredList<>(masterData, p -> true);
filterField.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate(person -> {
if (newValue == null || newValue.isEmpty()) {
return true;
}
String lowerCaseFilter = newValue.toLowerCase();
if (person.getFirstName().toLowerCase().contains(lowerCaseFilter)) {
return true;
} else if (person.getLastName().toLowerCase().contains(lowerCaseFilter)) {
return true;
}
return false;
});
});
SortedList<Person> sortedData = new SortedList<>(filteredData);sortedData.comparatorProperty().bind(personTable.comparatorProperty());
personTable.setItems(sortedData);
The following is SSCCE for my implementation with ListProperty
import java.util.ArrayList;
import java.util.List;
import javafx.application.Application;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.FloatProperty;
import javafx.beans.property.ListProperty;
import javafx.beans.property.ReadOnlyFloatProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.collections.transformation.SortedList;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class SortTable extends Application{
private ObservableList<Collection> collectionList = FXCollections.observableArrayList();
private ListProperty<Collection> collectionListProperty = new SimpleListProperty<>();
public static void main(String[] args) { launch(args); }
#Override
public void start(Stage primaryStage) throws Exception {
BorderPane borderPane = new BorderPane();
collectionList.setAll(getCollection());
TableView<Collection> tv = new TableView();
TextField sortTF = new TextField();
TableColumn<Collection, Number> colAmount = createAmountColumn();
TableColumn<Collection, String> colMno = createMNOColumn();
TableColumn<Collection, Number> colPrice = createPriceColumn();
TableColumn<Collection, Number> colQty = createQuantityColumn();
tv.getColumns().addAll(colMno, colQty, colPrice, colAmount);
collectionListProperty.set(collectionList);
tv.itemsProperty().bind(collectionListProperty);
FilteredList<Collection> filteredData = new FilteredList<>(collectionList, p -> true);
sortTF.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate(SaleTransaction -> {
if (newValue == null || newValue.isEmpty()) {
return true;
}
String lowerCaseFilter = newValue.toLowerCase();
if (SaleTransaction.getMno().toLowerCase().contains(lowerCaseFilter)) {
return true;
}
return false;
});
});
SortedList<Collection> sortedData = new SortedList<>(filteredData);
sortedData.comparatorProperty().bind(tv.comparatorProperty());
collectionList.setAll(sortedData);
borderPane.setTop(sortTF);
borderPane.setCenter(tv);
Scene scene = new Scene(borderPane, 600, 400);
primaryStage.setScene(scene);
primaryStage.show();
}
private TableColumn createQuantityColumn() {
TableColumn<Collection, Float> colQty = new TableColumn("Quantity");
colQty.setMinWidth(25);
colQty.setId("colQty");
colQty.setCellValueFactory(cellData -> cellData.getValue().quantityProperty().asObject());
return colQty;
}
private TableColumn createPriceColumn() {
TableColumn<Collection, Float> colPrice = new TableColumn("Price");
colPrice.setMinWidth(25);
colPrice.setId("colPrice");
colPrice.setCellValueFactory(cellData -> cellData.getValue().priceProperty().asObject());
return colPrice;
}
private TableColumn createAmountColumn() {
TableColumn<Collection, Float> colAmount = new TableColumn("Amount");
colAmount.setMinWidth(25);
colAmount.setId("colAmount");
colAmount.setCellValueFactory(cellData -> cellData.getValue().amountProperty().asObject());
return colAmount;
}
private TableColumn createMNOColumn() {
TableColumn colMNO = new TableColumn("M/NO");
colMNO.setMinWidth(25);
colMNO.setId("colMNO");
colMNO.setCellValueFactory(new PropertyValueFactory("mno"));
return colMNO;
}
private List<Collection> getCollection(){
List<Collection> collections = new ArrayList<>();
collections.add(new Collection(1, 10, "1", false));
collections.add(new Collection(2, 10, "12", true));
collections.add(new Collection(3, 10, "123", true));
collections.add(new Collection(4, 10, "312", true));
collections.add(new Collection(5, 10, "311", false));
collections.add(new Collection(6, 10, "322", true));
collections.add(new Collection(7, 10, "333", true));
collections.add(new Collection(8, 10, "321", false));
collections.add(new Collection(9, 10, "456", true));
collections.add(new Collection(10, 10, "551", true));
collections.add(new Collection(11, 10, "515", false));
collections.add(new Collection(12, 10, "134", true));
collections.add(new Collection(13, 10, "789", true));
collections.add(new Collection(14, 10, "879", false));
collections.add(new Collection(15, 10, "987", true));
collections.add(new Collection(16, 10, "856", true));
collections.add(new Collection(17, 10, "956", true));
collections.add(new Collection(18, 10, "589", true));
collections.add(new Collection(19, 10, "852", false));
collections.add(new Collection(20, 10, "456", false));
collections.add(new Collection(21, 10, "623", true));
collections.add(new Collection(22, 10, "147", false));
collections.add(new Collection(23, 10, "125", true));
collections.add(new Collection(24, 10, "258", false));
collections.add(new Collection(25, 10, "325", true));
collections.add(new Collection(26, 10, "753", true));
collections.add(new Collection(27, 10, "357", false));
collections.add(new Collection(28, 10, "159", false));
return collections;
}
public class Collection{
private final FloatProperty quantity = new SimpleFloatProperty();
private final FloatProperty price = new SimpleFloatProperty();
private final FloatProperty amount = new SimpleFloatProperty();
private final BooleanProperty paid = new SimpleBooleanProperty(false);
private String mno;
public Collection(){
this(0f, 0f, null, false);
}
public Collection(float quantity, float price, String mno, boolean paid) {
setQuantity(quantity);
setPrice(price);
setMno(mno);
setPaid(paid);
this.amount.bind(this.quantity.multiply(this.price));
}
public String getMno() {
return mno;
}
public void setMno(String mno) {
this.mno = mno;
}
public float getQuantity() {
return quantityProperty().get();
}
public void setQuantity(float quantity) {
quantityProperty().set(quantity);
}
public FloatProperty quantityProperty() {
return quantity ;
}
public float getPrice() {
return priceProperty().get();
}
public void setPrice(float price) {
priceProperty().set(price);
}
public FloatProperty priceProperty() {
return price ;
}
public float getAmount() {
return amountProperty().get();
}
public ReadOnlyFloatProperty amountProperty() {
return amount ;
}
public BooleanProperty paidProperty() {
return paid;
}
public void setPaid(boolean approved) {
this.paid.set(approved);
}
public boolean isPaid() {
return paid.get();
}
}
}
If I update a JList with a long number of html formatted items then the controls stop responding and indicators won't update. This makes sense, the event thread is busy. The title can still be set though. Why is this?
Here's some (long) code demonstrating this:
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.InvocationTargetException;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.*;
public class JListTest extends JFrame {
class TestListModel extends AbstractListModel<String> {
private static final long serialVersionUID = JListTest.serialVersionUID;
private boolean useHtml;
private String[] formattedList = new String[] {};
public int getSize() {
return formattedList.length;
}
public String getElementAt(int index) {
return formattedList[index];
}
public void setUseHtml(boolean useHtml) {
this.useHtml = useHtml;
}
public String getNewListItem() {
if (useHtml) {
return "<html><div style='padding:2px"
+ ";background-color:#EDF5F4;color:black'><div style='padding:2px;font-weight:500;'>"
+ "Item " + (100 * Math.random())
+ "</div>"
+ "This will change!"
+ "</div></html>";
} else {
return "Item " + (100 * Math.random());
}
}
public void updateItems() {
formattedList = new String[] {"<html><h1>Loading!</h1></html>"};
fireContentsChanged(this, 0, 1);
Thread buildItems = new Thread() {
#Override
public void run() {
final String[] tempList = new String[3000];
for (int i=0; i<tempList.length; i++) {
tempList[i] = getNewListItem();
}
// Just show the string bashing's done
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
formattedList = new String[] {"<html><h1>Updating!</h1></html>"};
fireContentsChanged(TestListModel.this, 0, 1);
}
});
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
// Update
SwingUtilities.invokeLater(new Runnable() {
public void run() {
formattedList = tempList;
fireContentsChanged(TestListModel.this, 0, formattedList.length);
}
});
}
};
buildItems.start();
}
}
protected static final long serialVersionUID = 1L;
public JListTest() {
JPanel controlPanel = new JPanel();
JButton updaterControl = new JButton("Add 3000");
final JCheckBox useHtmlControl = new JCheckBox("Use HTML");
final TestListModel model = new TestListModel();
JList<String> list = new JList<String>(model);
JScrollPane scrollPane = new JScrollPane(list);
final JLabel durationIndicator = new JLabel("0");
controlPanel.add(useHtmlControl, BorderLayout.WEST);
controlPanel.add(updaterControl, BorderLayout.EAST);
getContentPane().add(controlPanel, BorderLayout.PAGE_START);
getContentPane().add(scrollPane, BorderLayout.CENTER);
getContentPane().add(durationIndicator, BorderLayout.PAGE_END);
useHtmlControl.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
model.setUseHtml(useHtmlControl.isSelected());
}
});
useHtmlControl.setSelected(false);
updaterControl.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
model.updateItems();
}
});
Timer counter = new Timer();
counter.schedule(new TimerTask() {
#Override
public void run() {
String previousCounter = durationIndicator.getText();
String newCounter = Integer.toString(
Integer.parseInt(previousCounter) + 1);
durationIndicator.setText(newCounter);
setTitle(newCounter);
}
}, 0, 100);
}
public static void main(String args[]) {
JListTest jlt = new JListTest();
jlt.pack();
jlt.setSize(300, 300);
jlt.setVisible( true );
}
}
The answer is pretty obvious - because Window title is not a Swing component, it's OS native entity.
So changes don't have to go through Swing Event Queue, but go to XDecoratedPeer.updateWMName directly in case of Unix and to some other class in other OSes.
The more interesting question would be how to avoid that UI blocking, but I don't think that's possible with just Swing, you'll have to implement some lazy loading, or rendering in batches.
I'm trying to create donut chart using gwt-google-apis. As I understand based on the reference it's a ordinary pie chart with 'pieHole' option (it's value should be between 0.0 and 1.0). Also there is a restriction that donut does not support 'is3D' option.
I followed to the gwt-google-apis reference and wrote following code:
public void onModuleLoad() {
Runnable onLoadCallback = new Runnable() {
public void run() {
Panel panel = RootPanel.get();
PieChart pie = new PieChart(createTable(), createOptions());
panel.add(pie);
}
};
VisualizationUtils.loadVisualizationApi(onLoadCallback,
PieChart.PACKAGE);
}
private AbstractDataTable createTable() {
DataTable data = DataTable.create();
data.addColumn(ColumnType.STRING, "Task");
data.addColumn(ColumnType.NUMBER, "Hours per Day");
data.addRows(2);
data.setValue(0, 0, "Work");
data.setValue(0, 1, 14);
data.setValue(1, 0, "Sleep");
data.setValue(1, 1, 10);
return data;
}
private Options createOptions() {
Options options = Options.create();
options.setWidth(400);
options.setHeight(240);
options.setTitle("My Daily Activities");
options.setOption("pieHole", "0.4");
return options;
}
However, I've received ordinary pie chart without hole (I've run it only in dev mode). Any suggestions? Maybe I've missed something?
Looking at the API of latest stable version gwt-visualization-1.1.2, that functionality is not present. The only options specific to a piechart you can set are:
void set3D(boolean is3D)
void setPieResidueSliceLabel(java.lang.String label)
void setPieSliceText(java.lang.String text)
void setPieSliceTextStyle(TextStyle textStyle)
void setSliceVisibilityThreshold(double angle)
You could add an issue or write the functionality yourself adding JSNI methods to PieChart.PieOptions . Take a look at GWTProject if you are unfamiliar with this.
You can create donut chart using GWT-API
you have to write Wrapper for PieChartOptions like this
PieOpt.java
import com.google.gwt.core.client.JsArray;
import com.googlecode.gwt.charts.client.corechart.PieChartOptions;
import com.googlecode.gwt.charts.client.corechart.PieChartTooltip;
import com.googlecode.gwt.charts.client.options.BackgroundColor;
import com.googlecode.gwt.charts.client.options.ChartArea;
import com.googlecode.gwt.charts.client.options.Legend;
import com.googlecode.gwt.charts.client.options.PieSliceText;
import com.googlecode.gwt.charts.client.options.Slice;
import com.googlecode.gwt.charts.client.options.TextStyle;
public class PieOpt {
private PieChartOptions _this;
private PieOpt() {
_this = PieChartOptions.create();
}
public static PieOpt newInstance() {
return new PieOpt();
}
public PieChartOptions get() {
return _this;
}
public final void setBackgroundColor(BackgroundColor backgroundColor) {
_this.setBackgroundColor(backgroundColor);
}
public final void setBackgroundColor(String color) {
_this.setBackgroundColor(color);
}
public final void setChartArea(ChartArea chartArea) {
_this.setChartArea(chartArea);
}
public final void setColors(String... colors) {
_this.setColors(colors);
}
public final void setFontName(String name) {
_this.setFontName(name);
}
public final void setFontSize(double size) {
_this.setFontSize(size);
}
public final void setIs3D(boolean is3D) {
_this.setIs3D(is3D);
}
public final void setLegend(Legend legend) {
_this.setLegend(legend);
}
public final void setPieResidueSliceColor(String pieResidueSliceColor) {
_this.setPieResidueSliceColor(pieResidueSliceColor);
}
public final void setPieResidueSliceLabel(String pieResidueSliceLabel) {
_this.setPieResidueSliceLabel(pieResidueSliceLabel);
}
public final void setPieSliceBorderColor(String pieSliceBorderColor) {
_this.setPieSliceBorderColor(pieSliceBorderColor);
}
public final void setPieSliceText(PieSliceText pieSliceText) {
_this.setPieSliceText(pieSliceText);
}
public final void setPieSliceTextStyle(TextStyle pieSliceTextStyle) {
_this.setPieSliceTextStyle(pieSliceTextStyle);
}
public final void setReverseCategories(boolean reverseCategories) {
_this.setReverseCategories(reverseCategories);
}
public final void setSlices(JsArray<Slice> slices) {
_this.setSlices(slices);
}
public final void setSliceVisibilityThreshold(
double sliceVisibilityThreshold) {
_this.setSliceVisibilityThreshold(sliceVisibilityThreshold);
}
public final void setTitle(String title) {
_this.setTitle(title);
}
public final void setTitleTextStyle(TextStyle textStyle) {
_this.setTitleTextStyle(textStyle);
}
public final void setTooltip(PieChartTooltip tooltip) {
_this.setTooltip(tooltip);
}
public void setHole(double d) {
setHole(get(), d);
}
private final native void setHole(PieChartOptions chartOptions, double d) /*-{
chartOptions.pieHole = d;
}-*/;
}
And use it like this
ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART);
chartLoader.loadApi(new Runnable() {
#Override
public void run() {
pieChart = new PieChart();
DataTable dataTable = DataTable.create();
dataTable.addColumn(ColumnType.STRING, "Name");
dataTable.addColumn(ColumnType.NUMBER, "Donuts eaten");
dataTable.addRows(4);
dataTable.setValue(0, 0, "Michael");
dataTable.setValue(1, 0, "Elisa");
dataTable.setValue(2, 0, "Robert");
dataTable.setValue(3, 0, "John");
dataTable.setValue(0, 1, 5);
dataTable.setValue(1, 1, 7);
dataTable.setValue(2, 1, 3);
dataTable.setValue(3, 1, 2);
PieOpt opt = PieOpt.newInstance();
opt.setHole(0.4);
pieChart.draw(dataTable, opt.get());
}
});
And you are Done.
Try this:
FacetChart chart=new FacetChart();
chart.setData(ChartData.getData());
chart.setFacets(new Facet("region", "Region"),new Facet("time", "Period"));
chart.setValueProperty("value");
chart.setTitle("Revenue");
chart.setChartType(ChartType.DOUGHNUT);
Here a working example:
private PieChart.PieOptions createPieOptions() {
PieChart.PieOptions options = PieChart.createPieOptions();
options.set("pieHole", "0.4");
return options;
}
private AbstractDataTable createPieTable() {
DataTable data = DataTable.create();
data.addColumn(ColumnType.STRING, LABEL);
data.addColumn(ColumnType.NUMBER, VALUE);
data.addRows(2);
data.setValue(0, 0, "example");
data.setValue(0, 1, "12");
data.setValue(1, 0, "example number two");
data.setValue(1, 1, "88");
}
return data;
}
PieChart tagsPie = new PieChart(createPieTable(), createPieOptions());
I would like to use multiple-page editor (eclipse RCP). I want to follow this tutorial
but I cannot get "plug-in with multiple page editor" when I create a new project. I have only :
Hello
with a view
with an introduction
mail template
Does anyone have an idea about how to get the option plug-in with multiple page editor when creating a new RCP project?
Thnx
PS: I use Galileo 3.5.2
Please use the Eclipse Indigo instead.
Otherwise, you can create from the empty plugin project.
Here is my example of multiple pages editor. PropertyFileEditor is multiple pages editor. Hope this will help you.
FileDocumentProvider.java
package com.bosch.training.eclipseplugin.editors;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Map.Entry;
import java.util.Properties;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.MultiPageEditorPart;
import com.bosch.training.eclipseplugin.LinkedProperties;
public class PropertyFileEditor extends MultiPageEditorPart {
public static String EDITOR_ID = "com.bosch.training.eclipseplugin.editors.PropertyFileEditor";
private Text m_keyText;
private Text m_valueText;
private TableViewer m_tableViewer;
private IPath m_filePath;
private Properties m_properties;
private FileEditor m_firstPage;
public PropertyFileEditor() {
}
#Override
protected void createPages() {
try {
m_filePath = ((FileEditorInput) getEditorInput()).getFilePath();
m_firstPage = new FileEditor();
addPage(m_firstPage, (FileEditorInput) getEditorInput());
addPage(createDesignPage());
setPagesText();
} catch (PartInitException e) {
e.printStackTrace();
}
}
private void setPagesText() {
setPageText(0, "Plain Text");
setPageText(1, "Properties");
}
#Override
public void doSave(IProgressMonitor monitor) {
m_firstPage.doSave(monitor);
}
#Override
public void doSaveAs() {
}
#Override
public boolean isSaveAsAllowed() {
return false;
}
private Control createDesignPage() {
Composite parent = new Composite(getContainer(), SWT.NONE);
parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
parent.setLayout(new GridLayout(1, false));
// First row
Composite composite1 = new Composite(parent, SWT.NONE);
composite1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
composite1.setLayout(new GridLayout(3, false));
m_keyText = new Text(composite1, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
m_keyText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
m_keyText.setText("");
m_valueText = new Text(composite1, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
m_valueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
m_valueText.setText("");
Button applyButton = new Button(composite1, SWT.PUSH);
applyButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
applyButton.setText("Apply");
applyButton.addSelectionListener(new SelectionListener() {
#Override
public void widgetSelected(SelectionEvent e) {
m_properties.put(m_keyText.getText(), m_valueText.getText());
// Update table
TableItem tableItem= new TableItem(m_tableViewer.getTable(), SWT.NONE);
tableItem.setText(new String[] { m_keyText.getText(), m_valueText.getText() });
// Update editor
IDocument doc = m_firstPage.getDocumentProvider().getDocument(getEditorInput());
int offset;
try {
offset = doc.getLineOffset(doc.getNumberOfLines() - 1);
doc.replace(offset, 0, m_keyText.getText() + "=" + m_valueText.getText() + "\n");
} catch (BadLocationException ex) {
ex.printStackTrace();
}
// set text = ""
m_keyText.setText("");
m_valueText.setText("");
}
#Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// Second row
Composite composite2 = new Composite(parent, SWT.NONE);
composite2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
composite2.setLayout(new GridLayout(1, false));
m_tableViewer = new TableViewer(composite2, SWT.FILL);
Table table = m_tableViewer.getTable();
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TableColumn columnKey = new TableColumn(table, SWT.LEAD);
columnKey.setText("Key");
columnKey.setWidth(300);
TableColumn columnValue = new TableColumn(table, SWT.FILL);
columnValue.setText("Value");
columnValue.setWidth(300);
table.setHeaderVisible(true);
table.setLinesVisible(true);
m_tableViewer.setContentProvider(new IStructuredContentProvider() {
#Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
#Override
public void dispose() {
}
#Override
public Object[] getElements(Object inputElement) {
return (Object[]) inputElement;
}
});
m_tableViewer.setLabelProvider(new ITableLabelProvider() {
#Override
public void removeListener(ILabelProviderListener listener) {
}
#Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
#Override
public void dispose() {
}
#Override
public void addListener(ILabelProviderListener listener) {
}
#Override
public String getColumnText(Object element, int columnIndex) {
if (element instanceof Entry) {
switch (columnIndex) {
case 0:
return String.valueOf(((Entry) element).getKey());
case 1:
return String.valueOf(((Entry) element).getValue());
}
}
return "";
}
#Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
});
m_tableViewer.setInput(loadProperties());
m_firstPage.getDocumentProvider().getDocument(getEditorInput()).addDocumentListener(new IDocumentListener() {
#Override
public void documentChanged(DocumentEvent event) {
m_tableViewer.setInput(loadProperties());
}
#Override
public void documentAboutToBeChanged(DocumentEvent event) {
}
});
return parent;
}
private Object[] loadProperties() {
IDocument document = m_firstPage.getFileDocumentProvider().getDocument(getEditorInput());
m_properties = new LinkedProperties();
ByteArrayInputStream inputStream = null;
try {
inputStream = new ByteArrayInputStream(document.get().getBytes());
m_properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
return m_properties.entrySet().toArray();
}
}
FileEditor.java
package com.bosch.training.eclipseplugin.editors;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.ITextEditorExtension3;
public class FileEditor extends AbstractTextEditor {
public static final String EDITOR_ID = "com.bosch.training.eclipseplugin.editors.FileEditor";
private FileDocumentProvider m_fileDocumentProvider;
public FileEditor() {
setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope" });
internal_init();
}
protected void internal_init() {
configureInsertMode(ITextEditorExtension3.SMART_INSERT, false);
m_fileDocumentProvider = new FileDocumentProvider();
setDocumentProvider(m_fileDocumentProvider);
}
public FileDocumentProvider getFileDocumentProvider() {
return m_fileDocumentProvider;
}
}
FileEditorInput.java
package com.bosch.training.eclipseplugin.editors;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IPathEditorInput;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.PlatformUI;
public class FileEditorInput implements IPathEditorInput {
private IPath m_filePath;
public FileEditorInput(IPath path) {
if (path == null) {
throw new IllegalArgumentException();
}
this.m_filePath = path;
}
#Override
public int hashCode() {
return m_filePath.hashCode();
}
#Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof FileEditorInput)) {
return false;
}
FileEditorInput other = (FileEditorInput) obj;
return m_filePath.equals(other.m_filePath);
}
#Override
public boolean exists() {
return m_filePath.toFile().exists();
}
#Override
public ImageDescriptor getImageDescriptor() {
return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(m_filePath.toString());
}
#Override
public String getName() {
return m_filePath.toString();
}
#Override
public String getToolTipText() {
return m_filePath.makeRelative().toOSString();
}
#Override
public IPath getPath() {
return m_filePath;
}
#SuppressWarnings("rawtypes")
#Override
public Object getAdapter(Class adapter) {
return null;
}
#Override
public IPersistableElement getPersistable() {
// no persistence
return null;
}
public IPath getFilePath() {
return m_filePath;
}
public void setFilePath(IPath filePath) {
m_filePath = filePath;
}
}
PropertyFileEditor.java
package com.bosch.training.eclipseplugin.editors;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Map.Entry;
import java.util.Properties;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.MultiPageEditorPart;
import com.bosch.training.eclipseplugin.LinkedProperties;
public class PropertyFileEditor extends MultiPageEditorPart {
public static String EDITOR_ID = "com.bosch.training.eclipseplugin.editors.PropertyFileEditor";
private Text m_keyText;
private Text m_valueText;
private TableViewer m_tableViewer;
private IPath m_filePath;
private Properties m_properties;
private FileEditor m_firstPage;
public PropertyFileEditor() {
}
#Override
protected void createPages() {
try {
m_filePath = ((FileEditorInput) getEditorInput()).getFilePath();
m_firstPage = new FileEditor();
addPage(m_firstPage, (FileEditorInput) getEditorInput());
addPage(createDesignPage());
setPagesText();
} catch (PartInitException e) {
e.printStackTrace();
}
}
private void setPagesText() {
setPageText(0, "Plain Text");
setPageText(1, "Properties");
}
#Override
public void doSave(IProgressMonitor monitor) {
m_firstPage.doSave(monitor);
}
#Override
public void doSaveAs() {
}
#Override
public boolean isSaveAsAllowed() {
return false;
}
private Control createDesignPage() {
Composite parent = new Composite(getContainer(), SWT.NONE);
parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
parent.setLayout(new GridLayout(1, false));
// First row
Composite composite1 = new Composite(parent, SWT.NONE);
composite1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
composite1.setLayout(new GridLayout(3, false));
m_keyText = new Text(composite1, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
m_keyText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
m_keyText.setText("");
m_valueText = new Text(composite1, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
m_valueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
m_valueText.setText("");
Button applyButton = new Button(composite1, SWT.PUSH);
applyButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
applyButton.setText("Apply");
applyButton.addSelectionListener(new SelectionListener() {
#Override
public void widgetSelected(SelectionEvent e) {
m_properties.put(m_keyText.getText(), m_valueText.getText());
// Update table
TableItem tableItem= new TableItem(m_tableViewer.getTable(), SWT.NONE);
tableItem.setText(new String[] { m_keyText.getText(), m_valueText.getText() });
// Update editor
IDocument doc = m_firstPage.getDocumentProvider().getDocument(getEditorInput());
int offset;
try {
offset = doc.getLineOffset(doc.getNumberOfLines() - 1);
doc.replace(offset, 0, m_keyText.getText() + "=" + m_valueText.getText() + "\n");
} catch (BadLocationException ex) {
ex.printStackTrace();
}
// set text = ""
m_keyText.setText("");
m_valueText.setText("");
}
#Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// Second row
Composite composite2 = new Composite(parent, SWT.NONE);
composite2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
composite2.setLayout(new GridLayout(1, false));
m_tableViewer = new TableViewer(composite2, SWT.FILL);
Table table = m_tableViewer.getTable();
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TableColumn columnKey = new TableColumn(table, SWT.LEAD);
columnKey.setText("Key");
columnKey.setWidth(300);
TableColumn columnValue = new TableColumn(table, SWT.FILL);
columnValue.setText("Value");
columnValue.setWidth(300);
table.setHeaderVisible(true);
table.setLinesVisible(true);
m_tableViewer.setContentProvider(new IStructuredContentProvider() {
#Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
#Override
public void dispose() {
}
#Override
public Object[] getElements(Object inputElement) {
return (Object[]) inputElement;
}
});
m_tableViewer.setLabelProvider(new ITableLabelProvider() {
#Override
public void removeListener(ILabelProviderListener listener) {
}
#Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
#Override
public void dispose() {
}
#Override
public void addListener(ILabelProviderListener listener) {
}
#Override
public String getColumnText(Object element, int columnIndex) {
if (element instanceof Entry) {
switch (columnIndex) {
case 0:
return String.valueOf(((Entry) element).getKey());
case 1:
return String.valueOf(((Entry) element).getValue());
}
}
return "";
}
#Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
});
m_tableViewer.setInput(loadProperties());
m_firstPage.getDocumentProvider().getDocument(getEditorInput()).addDocumentListener(new IDocumentListener() {
#Override
public void documentChanged(DocumentEvent event) {
m_tableViewer.setInput(loadProperties());
}
#Override
public void documentAboutToBeChanged(DocumentEvent event) {
}
});
return parent;
}
private Object[] loadProperties() {
IDocument document = m_firstPage.getFileDocumentProvider().getDocument(getEditorInput());
m_properties = new LinkedProperties();
ByteArrayInputStream inputStream = null;
try {
inputStream = new ByteArrayInputStream(document.get().getBytes());
m_properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
return m_properties.entrySet().toArray();
}
}
I cannot tell you, if this template is available in Galileo. It is in Indigo.
But this template just combines two steps you can do on your own. Create an empty plugin project, open the MANIFEST.MF to open the plugin editor and select the extension tabs.
There you can add extension for editors and for wizards.
For a multipage editor click on Add, then select org.eclipse.ui.editors. In the template area at the bottom of the dialog select Multi-Page editor. Then enter the properties as show in your tutorial.
Repeat for the new wizard by selectin org.eclipse.ui.newWizard and the New File Wizard template.