eclipsefinance-subversion Mailing List for Eclipse Finance
Status: Pre-Alpha
Brought to you by:
yukio7
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(22) |
Oct
(1) |
Nov
|
Dec
|
|---|
|
From: <yu...@us...> - 2006-10-09 14:36:27
|
Revision: 36
http://svn.sourceforge.net/eclipsefinance/?rev=36&view=rev
Author: yukio7
Date: 2006-10-09 07:35:49 -0700 (Mon, 09 Oct 2006)
Log Message:
-----------
transaction and account views viewable
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/plugin.xml
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ObservableList.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Bank.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountSelection.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/CoreFinanceAdapterFactory.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewBankAction.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountsView.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java
Added Paths:
-----------
trunk/net.sf.eclipsefinance.core/icons/etool16/
trunk/net.sf.eclipsefinance.core/icons/etool16/book_add.png
trunk/net.sf.eclipsefinance.core/icons/etool16/coins_add.png
trunk/net.sf.eclipsefinance.core/icons/eview16/
trunk/net.sf.eclipsefinance.core/icons/eview16/book.png
trunk/net.sf.eclipsefinance.core/icons/eview16/coins.png
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountGroupSelection.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewAccountGroupAction.java
Added: trunk/net.sf.eclipsefinance.core/icons/etool16/book_add.png
===================================================================
(Binary files differ)
Property changes on: trunk/net.sf.eclipsefinance.core/icons/etool16/book_add.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/net.sf.eclipsefinance.core/icons/etool16/coins_add.png
===================================================================
(Binary files differ)
Property changes on: trunk/net.sf.eclipsefinance.core/icons/etool16/coins_add.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/net.sf.eclipsefinance.core/icons/eview16/book.png
===================================================================
(Binary files differ)
Property changes on: trunk/net.sf.eclipsefinance.core/icons/eview16/book.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/net.sf.eclipsefinance.core/icons/eview16/coins.png
===================================================================
(Binary files differ)
Property changes on: trunk/net.sf.eclipsefinance.core/icons/eview16/coins.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/net.sf.eclipsefinance.core/plugin.xml
===================================================================
--- trunk/net.sf.eclipsefinance.core/plugin.xml 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/plugin.xml 2006-10-09 14:35:49 UTC (rev 36)
@@ -2,12 +2,24 @@
<?eclipse version="3.2"?>
<plugin>
<extension
- point="org.eclipse.ui.perspectives">
- <perspective
- name="Core"
- class="net.sf.eclipsefinance.core.ui.perspectives.CorePerspective"
- id="net.sf.eclipsefinance.core.perspectives.CorePerspective">
- </perspective>
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension targetID="net.sf.eclipsefinance.core.perspectives.CorePerspective">
+ <view
+ closeable="true"
+ id="net.sf.eclipsefinance.core.ui.views.Accountsiew"
+ moveable="true"
+ relationship="stack"
+ relative="left"
+ visible="true"/>
+ <view
+ closeable="true"
+ id="net.sf.eclipsefinance.core.ui.views.TransactionsView"
+ moveable="true"
+ ratio="0.7"
+ relationship="stack"
+ relative="center"
+ visible="true"/>
+ </perspectiveExtension>
</extension>
<extension
point="org.eclipse.ui.views">
@@ -19,15 +31,16 @@
allowMultiple="false"
category="net.sf.eclipsefinance.core"
class="net.sf.eclipsefinance.core.ui.views.AccountsView"
- icon="icons/sample.gif"
+ icon="icons/eview16/coins.png"
id="net.sf.eclipsefinance.core.ui.views.Accountsiew"
name="%view.name.accounts">
</view>
- <view
- category="net.sf.eclipsefinance.core"
- class="net.sf.eclipsefinance.core.ui.views.TransactionsView"
- icon="icons/sample.gif"
- id="net.sf.eclipsefinance.core.ui.views.TransactionsView"
+ <view
+ allowMultiple="true"
+ category="net.sf.eclipsefinance.core"
+ class="net.sf.eclipsefinance.core.ui.views.TransactionsView"
+ icon="icons/eview16/book.png"
+ id="net.sf.eclipsefinance.core.ui.views.TransactionsView"
name="%view.name.transactions"/>
</extension>
<extension
@@ -51,12 +64,33 @@
label="%actionSet.label.core"
visible="true">
<action
+ icon="icons/etool16/book_add.png"
id="net.sf.eclipsefinance.core.ui.action.newTransaction"
label="%action.label.newTransaction"
menubarPath="file/newWizards/newTransaction"
style="push"
toolbarPath="core"/>
+ <action
+ icon="icons/etool16/coins_add.png"
+ id="net.sf.eclipsefinance.core.ui.action.newAccount"
+ label="New Account"
+ menubarPath="file/newWizards/newAccount"
+ style="push"
+ toolbarPath="core"/>
</actionSet>
</extension>
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ class="net.sf.eclipsefinance.core.ui.perspectives.CorePerspective"
+ id="net.sf.eclipsefinance.core.perspectives.CorePerspective"
+ name="CorePerspective"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.activities">
+ <activityPatternBinding
+ activityId="net.sf.eclipsefinance.core/net.sf.eclipsefinance.views.transactions"
+ pattern="net.sf.eclipsefinance.core/net.sf.eclipsetrader.views.transactions"/>
+ </extension>
</plugin>
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ObservableList.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ObservableList.java 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ObservableList.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -15,20 +15,18 @@
import java.util.Collection;
import java.util.List;
-
-/**
- */
public class ObservableList extends ArrayList
{
private static final long serialVersionUID = 7282371672763711235L;
private List originalList;
- private List observers = new ArrayList();
+ private List<ICollectionObserver> observers = new ArrayList<ICollectionObserver>();
public ObservableList()
{
}
- public ObservableList(List list)
+ @SuppressWarnings("unchecked")
+ public ObservableList(List list)
{
super(list);
this.originalList = list;
@@ -72,7 +70,8 @@
/* (non-Javadoc)
* @see java.util.ArrayList#add(java.lang.Object)
*/
- public boolean add(Object o)
+ @SuppressWarnings("unchecked")
+ public boolean add(Object o)
{
boolean result = super.add(o);
if (originalList != null)
@@ -84,7 +83,8 @@
/* (non-Javadoc)
* @see java.util.ArrayList#add(int, java.lang.Object)
*/
- public void add(int index, Object element)
+ @SuppressWarnings("unchecked")
+ public void add(int index, Object element)
{
super.add(index, element);
if (originalList != null)
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -14,7 +14,8 @@
private Currency currency = null;
private String IBAN = null;
private BigDecimal balance = new BigDecimal("0.0");
- private Bank bank = null;
+// private Bank bank = null;
+ private AccountGroup group = null;
List transactionList = new ArrayList();
Account(String name){
@@ -54,12 +55,20 @@
this.balance = balance;
}
- public Bank getBank() {
- return this.bank;
+// public Bank getBank() {
+// return this.bank;
+// }
+//
+// public void setBank(Bank bank) {
+// this.bank = bank;
+// }
+
+ public AccountGroup getGroup() {
+ return this.group;
}
- public void setBank(Bank bank) {
- this.bank = bank;
+ public void setGroup(AccountGroup group) {
+ this.group = group;
}
public List getTransactionList() {
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2006 Marco Maccaferri and others.
+ * Copyright (c) 2006 Eclipse Finance.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,12 +7,11 @@
*
* Contributors:
* Marco Maccaferri - initial API and implementation
+ * Francois Cottet - adaptation for Eclipse Finance
*/
package net.sf.eclipsefinance.core.model;
-import java.util.Iterator;
-
import net.sf.eclipsefinance.core.ObservableList;
import net.sf.eclipsefinance.core.persistence.PersistentObject;
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Bank.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Bank.java 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Bank.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -45,12 +45,14 @@
public void addAccount(Account newAccount){
this.accountList.add(newAccount);
- newAccount.setBank(this);
+// newAccount.setBank(this);
+ newAccount.setGroup(this);
}
public void removeAccount(Account oldAccount){
this.accountList.remove(oldAccount);
- oldAccount.setBank(null);
+// oldAccount.setBank(null);
+ oldAccount.setGroup(null);
}
public Integer getId() {
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountGroupSelection.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountGroupSelection.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountGroupSelection.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2004-2006 Marco Maccaferri and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ */
+
+package net.sf.eclipsefinance.core.ui;
+
+import net.sf.eclipsefinance.core.model.AccountGroup;
+
+import org.eclipse.jface.viewers.ISelection;
+
+public class AccountGroupSelection implements ISelection
+{
+ private AccountGroup group;
+
+ public AccountGroupSelection(AccountGroup group)
+ {
+ this.group = group;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelection#isEmpty()
+ */
+ public boolean isEmpty()
+ {
+ return (group == null);
+ }
+
+ public AccountGroup getGroup()
+ {
+ return group;
+ }
+}
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountSelection.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountSelection.java 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountSelection.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -13,13 +13,13 @@
import net.sf.eclipsefinance.core.model.Account;
-public class AccountSelection extends BankSelection
+public class AccountSelection extends AccountGroupSelection
{
private Account account;
public AccountSelection(Account account)
{
- super(account.getBank());
+ super(account.getGroup());
this.account = account;
}
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/CoreFinanceAdapterFactory.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/CoreFinanceAdapterFactory.java 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/CoreFinanceAdapterFactory.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -81,7 +81,7 @@
private IWorkbenchAdapter accountAdapter = new IWorkbenchAdapter(){
public Object getParent(Object o){
- return ((Account)o).getBank();
+ return ((Account)o).getGroup();
}
public String getLabel(Object o){
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewAccountGroupAction.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewAccountGroupAction.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewAccountGroupAction.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ * Francois Cottet - adaptation for Eclipse Finance
+ */
+
+
+package net.sf.eclipsefinance.core.ui.actions;
+
+import net.sf.eclipsefinance.core.model.AccountGroup;
+import net.sf.eclipsefinance.core.ui.AccountGroupSelection;
+import net.sf.eclipsefinance.core.ui.AccountSelection;
+import net.sf.eclipsefinance.core.ui.views.AccountsView;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ISelection;
+
+public class NewAccountGroupAction extends Action
+{
+ private AccountsView view;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
+ */
+ public NewAccountGroupAction(AccountsView view)
+ {
+ this.view = view;
+ setText("Create Group");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run()
+ {
+ InputDialog dlg = new InputDialog(view.getViewSite().getShell(), getText(), "Enter the name of the group to create:", null, null);
+ if (dlg.open() == InputDialog.OK && dlg.getValue() != null)
+ {
+ AccountGroup group = new AccountGroup();
+ group.setDescription(dlg.getValue());
+
+ ISelection selection = view.getSite().getSelectionProvider().getSelection();
+ if (selection instanceof AccountSelection)
+ group.setParent(((AccountSelection)selection).getAccount().getGroup());
+ else if (selection instanceof AccountGroupSelection)
+ group.setParent(((AccountGroupSelection)selection).getGroup());
+
+// CorePlugin.getRepository().save(group);
+ }
+ }
+}
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewBankAction.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewBankAction.java 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewBankAction.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -19,7 +19,6 @@
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.viewers.ISelection;
public class NewBankAction extends Action
{
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountsView.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountsView.java 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountsView.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -349,7 +349,7 @@
for (Iterator iter = list.iterator(); iter.hasNext(); )
{
Account account = (Account)iter.next();
- if (account.getBank() == null)
+ if (account.getGroup() == null)
new AccountTreeItem(account, tree, SWT.NONE);
}
@@ -439,7 +439,7 @@
if (o instanceof Account)
{
Account account = (Account)o;
- if (account.getBank() != null)
+ if (account.getGroup() != null)
return;
TreeItem items[] = tree.getItems();
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java 2006-09-22 12:52:57 UTC (rev 35)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java 2006-10-09 14:35:49 UTC (rev 36)
@@ -168,7 +168,9 @@
table.setMenu(menuMgr.createContextMenu(table));
getSite().registerContextMenu(menuMgr, getSite().getSelectionProvider());
- account = (Account)Fortune.getInstance().getAccount(new Integer(Integer.parseInt(getViewSite().getSecondaryId())));
+ String id = getViewSite().getSecondaryId();
+ if(id!=null)
+ account = (Account)Fortune.getInstance().getAccount(new Integer(Integer.parseInt(id)));
if (account != null)
{
setTitleToolTip(account.getName());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-22 12:53:10
|
Revision: 35
http://svn.sourceforge.net/eclipsefinance/?rev=35&view=rev
Author: yukio7
Date: 2006-09-22 05:52:57 -0700 (Fri, 22 Sep 2006)
Log Message:
-----------
fix: compilation errors
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Account.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/AccountGroup.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Repository.java
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java 2006-09-21 12:09:06 UTC (rev 34)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java 2006-09-22 12:52:57 UTC (rev 35)
@@ -68,15 +68,15 @@
if (accounts == null)
{
accounts = new ObservableList();
- if (getRepository() != null)
- {
- for (Iterator iter = getRepository().allAccounts().iterator(); iter.hasNext(); )
- {
- Account account = (Account) iter.next();
- if (this.equals(account.getGroup()))
- accounts.add(account);
- }
- }
+// if (getRepository() != null)
+// {
+// for (Iterator iter = getRepository().allAccounts().iterator(); iter.hasNext(); )
+// {
+// Account account = (Account) iter.next();
+// if (this.equals(account.getGroup()))
+// accounts.add(account);
+// }
+// }
}
return accounts;
}
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Account.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Account.java 2006-09-21 12:09:06 UTC (rev 34)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Account.java 2006-09-22 12:52:57 UTC (rev 35)
@@ -177,82 +177,82 @@
for (int i = 0; i < objs.length; i++)
{
Transaction transaction = (Transaction)objs[i];
- double amount = transaction.getAmount();
- if (getCurrency() != null && !getCurrency().equals(transaction.getSecurity().getCurrency()))
- amount = CurrencyConverter.getInstance().convert(transaction.getDate(), amount, transaction.getSecurity().getCurrency(), getCurrency());
+ double amount = transaction.getAmount().doubleValue();
+// if (getCurrency() != null && !getCurrency().equals(transaction.getSecurity().getCurrency()))
+// amount = CurrencyConverter.getInstance().convert(transaction.getDate(), amount, transaction.getSecurity().getCurrency(), getCurrency());
result += amount;
}
return result;
}
- /**
- * Return the number of stocks held for the given security.
- *
- * @param security the security to search
- * @return holded quantity
- */
- public int getPosition(Security security)
- {
- int result = 0;
-
- Object[] objs = getTransactions().toArray();
- for (int i = 0; i < objs.length; i++)
- {
- Transaction transaction = (Transaction)objs[i];
- if (transaction.getSecurity().equals(security))
- result += transaction.getQuantity();
- }
-
- return result;
- }
+// /**
+// * Return the number of stocks held for the given security.
+// *
+// * @param security the security to search
+// * @return holded quantity
+// */
+// public int getPosition(Security security)
+// {
+// int result = 0;
+//
+// Object[] objs = getTransactions().toArray();
+// for (int i = 0; i < objs.length; i++)
+// {
+// Transaction transaction = (Transaction)objs[i];
+// if (transaction.getSecurity().equals(security))
+// result += transaction.getQuantity();
+// }
+//
+// return result;
+// }
- public List getPortfolio()
- {
- List result = new ArrayList();
-
- Map map = new HashMap();
- for (Iterator iter2 = getTransactions().iterator(); iter2.hasNext(); )
- {
- Transaction transaction = (Transaction)iter2.next();
- PortfolioPosition position = (PortfolioPosition)map.get(transaction.getSecurity());
- if (position == null)
- map.put(transaction.getSecurity(), new PortfolioPosition(this, transaction.getSecurity(), transaction.getQuantity(), transaction.getAmount()));
- else
- position.add(transaction.getQuantity(), transaction.getAmount());
- }
-
- List list = new ArrayList(map.keySet());
- Collections.sort(list, new Comparator() {
- public int compare(Object arg0, Object arg1)
- {
- return ((Security)arg0).getDescription().compareTo(((Security)arg1).getDescription());
- }
- });
- for (Iterator iter = list.iterator(); iter.hasNext(); )
- {
- Security security = (Security)iter.next();
- PortfolioPosition position = (PortfolioPosition)map.get(security);
- if (position.getQuantity() != 0)
- result.add(position);
- }
-
- return result;
- }
+// public List getPortfolio()
+// {
+// List result = new ArrayList();
+//
+// Map map = new HashMap();
+// for (Iterator iter2 = getTransactions().iterator(); iter2.hasNext(); )
+// {
+// Transaction transaction = (Transaction)iter2.next();
+// PortfolioPosition position = (PortfolioPosition)map.get(transaction.getSecurity());
+// if (position == null)
+// map.put(transaction.getSecurity(), new PortfolioPosition(this, transaction.getSecurity(), transaction.getQuantity(), transaction.getAmount()));
+// else
+// position.add(transaction.getQuantity(), transaction.getAmount());
+// }
+//
+// List list = new ArrayList(map.keySet());
+// Collections.sort(list, new Comparator() {
+// public int compare(Object arg0, Object arg1)
+// {
+// return ((Security)arg0).getDescription().compareTo(((Security)arg1).getDescription());
+// }
+// });
+// for (Iterator iter = list.iterator(); iter.hasNext(); )
+// {
+// Security security = (Security)iter.next();
+// PortfolioPosition position = (PortfolioPosition)map.get(security);
+// if (position.getQuantity() != 0)
+// result.add(position);
+// }
+//
+// return result;
+// }
- public PortfolioPosition getPortfolio(Security security)
- {
- PortfolioPosition position = new PortfolioPosition(this, security, 0, 0);
-
- for (Iterator iter2 = getTransactions().iterator(); iter2.hasNext(); )
- {
- Transaction transaction = (Transaction)iter2.next();
- if (position.getSecurity().equals(transaction.getSecurity()))
- position.add(transaction.getQuantity(), transaction.getAmount());
- }
-
- return position;
- }
+// public PortfolioPosition getPortfolio(Security security)
+// {
+// PortfolioPosition position = new PortfolioPosition(this, security, 0, 0);
+//
+// for (Iterator iter2 = getTransactions().iterator(); iter2.hasNext(); )
+// {
+// Transaction transaction = (Transaction)iter2.next();
+// if (position.getSecurity().equals(transaction.getSecurity()))
+// position.add(transaction.getQuantity(), transaction.getAmount());
+// }
+//
+// return position;
+// }
public double getExpenses(Security security, int quantity, double price)
{
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/AccountGroup.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/AccountGroup.java 2006-09-21 12:09:06 UTC (rev 34)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/AccountGroup.java 2006-09-22 12:52:57 UTC (rev 35)
@@ -14,7 +14,7 @@
import java.util.Iterator;
-import net.sourceforge.eclipsetrader.core.ObservableList;
+import net.sf.eclipsefinance.core.ObservableList;
public class AccountGroup extends PersistentObject
{
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Repository.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Repository.java 2006-09-21 12:09:06 UTC (rev 34)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Repository.java 2006-09-22 12:52:57 UTC (rev 35)
@@ -12,26 +12,12 @@
package net.sf.eclipsefinance.core.persistence;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Observable;
import net.sf.eclipsefinance.core.ObservableList;
-import net.sourceforge.eclipsetrader.core.db.Account;
-import net.sourceforge.eclipsetrader.core.db.AccountGroup;
-import net.sourceforge.eclipsetrader.core.db.Chart;
-import net.sourceforge.eclipsetrader.core.db.Event;
-import net.sourceforge.eclipsetrader.core.db.NewsItem;
-import net.sourceforge.eclipsetrader.core.db.Order;
-import net.sourceforge.eclipsetrader.core.db.PersistentObject;
-import net.sourceforge.eclipsetrader.core.db.Security;
-import net.sourceforge.eclipsetrader.core.db.SecurityGroup;
-import net.sourceforge.eclipsetrader.core.db.Watchlist;
-import net.sourceforge.eclipsetrader.core.db.WatchlistItem;
-import net.sourceforge.eclipsetrader.core.db.trading.TradingSystem;
/**
@@ -141,12 +127,12 @@
if (obj instanceof Account)
{
- TradingSystem[] systems = (TradingSystem[])getTradingSystems().toArray(new TradingSystem[0]);
- for (int i = 0; i < systems.length; i++)
- {
- if (obj.equals(systems[i].getAccount()))
- delete(systems[i]);
- }
+// TradingSystem[] systems = (TradingSystem[])getTradingSystems().toArray(new TradingSystem[0]);
+// for (int i = 0; i < systems.length; i++)
+// {
+// if (obj.equals(systems[i].getAccount()))
+// delete(systems[i]);
+// }
allAccounts().remove(obj);
if (((Account)obj).getGroup() != null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-21 12:09:10
|
Revision: 34
http://svn.sourceforge.net/eclipsefinance/?rev=34&view=rev
Author: yukio7
Date: 2006-09-21 05:09:06 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
.settings no more in svn
Property Changed:
----------------
trunk/net.sf.eclipsefinance.core/
Property changes on: trunk/net.sf.eclipsefinance.core
___________________________________________________________________
Name: svn:ignore
+ .settings
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-21 12:07:33
|
Revision: 33
http://svn.sourceforge.net/eclipsefinance/?rev=33&view=rev
Author: yukio7
Date: 2006-09-21 05:07:27 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
.settings no more in svn
Property Changed:
----------------
trunk/net.sf.eclipsefinance/
Property changes on: trunk/net.sf.eclipsefinance
___________________________________________________________________
Name: svn:ignore
+ .settings
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
Revision: 32
http://svn.sourceforge.net/eclipsefinance/?rev=32&view=rev
Author: yukio7
Date: 2006-09-21 05:05:04 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
formatting: @SuppressWarnings("unchecked") in getColor(RGB)
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/ColorManager.java
Modified: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/ColorManager.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/ColorManager.java 2006-09-21 12:04:15 UTC (rev 31)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/ColorManager.java 2006-09-21 12:05:04 UTC (rev 32)
@@ -17,6 +17,7 @@
while (e.hasNext())
((Color) e.next()).dispose();
}
+ @SuppressWarnings("unchecked")
public Color getColor(RGB rgb) {
Color color = (Color) fColorTable.get(rgb);
if (color == null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-21 12:04:24
|
Revision: 31
http://svn.sourceforge.net/eclipsefinance/?rev=31&view=rev
Author: yukio7
Date: 2006-09-21 05:04:15 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
fix: error in classname of CSVEditor
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.converter.ubs/plugin.xml
Modified: trunk/net.sf.eclipsefinance.converter.ubs/plugin.xml
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/plugin.xml 2006-09-21 12:03:18 UTC (rev 30)
+++ trunk/net.sf.eclipsefinance.converter.ubs/plugin.xml 2006-09-21 12:04:15 UTC (rev 31)
@@ -9,8 +9,8 @@
extensions="csv"
icon="icons/sample.gif"
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
- class="net.sf.eclipsefinance.converter.ubs.editors.CSV Editor"
- id="net.sf.eclipsefinance.converter.ubs.editors.CSV Editor">
+ class="net.sf.eclipsefinance.converter.ubs.editors.CSVEditor"
+ id="net.sf.eclipsefinance.converter.ubs.editors.CSVEditor">
</editor>
</extension>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-21 12:03:25
|
Revision: 30
http://svn.sourceforge.net/eclipsefinance/?rev=30&view=rev
Author: yukio7
Date: 2006-09-21 05:03:18 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
plugin updated (new actions and views)
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/META-INF/MANIFEST.MF
trunk/net.sf.eclipsefinance.core/plugin.xml
Modified: trunk/net.sf.eclipsefinance.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/net.sf.eclipsefinance.core/META-INF/MANIFEST.MF 2006-09-21 12:02:53 UTC (rev 29)
+++ trunk/net.sf.eclipsefinance.core/META-INF/MANIFEST.MF 2006-09-21 12:03:18 UTC (rev 30)
@@ -3,10 +3,8 @@
Bundle-Name: EclispeFinance Core Plug-in
Bundle-SymbolicName: net.sf.eclipsefinance.core; singleton:=true
Bundle-Version: 0.0.1
-Bundle-Activator: net.sf.eclipsefinance.core.Activator
+Bundle-Activator: net.sf.eclipsefinance.core.CoreActivator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.ui.views,
- org.eclipse.ui.views.properties.tabbed
+ org.eclipse.core.runtime
Eclipse-LazyStart: true
Modified: trunk/net.sf.eclipsefinance.core/plugin.xml
===================================================================
--- trunk/net.sf.eclipsefinance.core/plugin.xml 2006-09-21 12:02:53 UTC (rev 29)
+++ trunk/net.sf.eclipsefinance.core/plugin.xml 2006-09-21 12:03:18 UTC (rev 30)
@@ -4,9 +4,9 @@
<extension
point="org.eclipse.ui.perspectives">
<perspective
- name="Account"
- class="net.sf.eclipsefinance.core.ui.views.CorePerspective"
- id="net.sf.eclipsefinance.core.views.CorePerspective">
+ name="Core"
+ class="net.sf.eclipsefinance.core.ui.perspectives.CorePerspective"
+ id="net.sf.eclipsefinance.core.perspectives.CorePerspective">
</perspective>
</extension>
<extension
@@ -18,17 +18,17 @@
<view
allowMultiple="false"
category="net.sf.eclipsefinance.core"
- class="net.sf.eclipsefinance.core.ui.views.AccountView"
+ class="net.sf.eclipsefinance.core.ui.views.AccountsView"
icon="icons/sample.gif"
- id="net.sf.eclipsefinance.core.ui.views.AccountView"
- name="Account View">
+ id="net.sf.eclipsefinance.core.ui.views.Accountsiew"
+ name="%view.name.accounts">
</view>
<view
category="net.sf.eclipsefinance.core"
- class="net.sf.eclipsefinance.core.ui.view.TransactionsView"
+ class="net.sf.eclipsefinance.core.ui.views.TransactionsView"
icon="icons/sample.gif"
- id="net.sf.eclipsefinance.core.ui.view.TransactionsView"
- name="Transactions View"/>
+ id="net.sf.eclipsefinance.core.ui.views.TransactionsView"
+ name="%view.name.transactions"/>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
@@ -42,5 +42,21 @@
</view>
</perspectiveExtension>
</extension>
+ <extension
+ id="net.sf.eclipsefinance.actions"
+ name="Actions"
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ id="net.sf.eclipsefinance.actions"
+ label="%actionSet.label.core"
+ visible="true">
+ <action
+ id="net.sf.eclipsefinance.core.ui.action.newTransaction"
+ label="%action.label.newTransaction"
+ menubarPath="file/newWizards/newTransaction"
+ style="push"
+ toolbarPath="core"/>
+ </actionSet>
+ </extension>
</plugin>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-21 12:02:58
|
Revision: 29
http://svn.sourceforge.net/eclipsefinance/?rev=29&view=rev
Author: yukio7
Date: 2006-09-21 05:02:53 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
new file for translations
Added Paths:
-----------
trunk/net.sf.eclipsefinance.core/plugin.properties
Added: trunk/net.sf.eclipsefinance.core/plugin.properties
===================================================================
--- trunk/net.sf.eclipsefinance.core/plugin.properties (rev 0)
+++ trunk/net.sf.eclipsefinance.core/plugin.properties 2006-09-21 12:02:53 UTC (rev 29)
@@ -0,0 +1,5 @@
+# properties file for net.sf.eclipsefinance.core
+actionSet.label.core = Actions
+action.label.newTransaction = New Transaction
+view.name.accounts = Accounts
+view.name.transactions = Transactions
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-21 12:02:43
|
Revision: 28
http://svn.sourceforge.net/eclipsefinance/?rev=28&view=rev
Author: yukio7
Date: 2006-09-21 05:02:34 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
refactoring of CorePerspective
Modified Paths:
--------------
trunk/net.sf.eclipsefinance/src/net/sf/eclipsefinance/ApplicationWorkbenchAdvisor.java
Modified: trunk/net.sf.eclipsefinance/src/net/sf/eclipsefinance/ApplicationWorkbenchAdvisor.java
===================================================================
--- trunk/net.sf.eclipsefinance/src/net/sf/eclipsefinance/ApplicationWorkbenchAdvisor.java 2006-09-21 12:01:54 UTC (rev 27)
+++ trunk/net.sf.eclipsefinance/src/net/sf/eclipsefinance/ApplicationWorkbenchAdvisor.java 2006-09-21 12:02:34 UTC (rev 28)
@@ -1,6 +1,6 @@
package net.sf.eclipsefinance;
-import net.sf.eclipsefinance.core.ui.views.CorePerspective;
+import net.sf.eclipsefinance.core.ui.perspectives.CorePerspective;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-21 12:02:26
|
Revision: 27
http://svn.sourceforge.net/eclipsefinance/?rev=27&view=rev
Author: yukio7
Date: 2006-09-21 05:01:54 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
work in progress (AccountGroup, new actions, wizards)
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Bank.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Fortune.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/TransactionDialog.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountView.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java
Added Paths:
-----------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/CoreActivator.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ICollectionObserver.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ObservableList.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Account.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/AccountGroup.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/PersistentObject.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/PersistentPreferenceStore.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Repository.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Transaction.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountSelection.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/BankSelection.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/CoreFinanceAdapterFactory.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/NullSelection.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/SelectionProvider.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewAccountAction.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewBankAction.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/NewTransactionAction.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/actions/TransactionAction.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/perspectives/
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/perspectives/CorePerspective.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountsView.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/wizards/
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/wizards/NewAccountWizard.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/wizards/PluginSelectionPage.java
Removed Paths:
-------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/Activator.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/CoreFinanceAdapterFactory.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/CorePerspective.java
Deleted: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/Activator.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/Activator.java 2006-09-20 17:59:38 UTC (rev 26)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/Activator.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -1,61 +0,0 @@
-package net.sf.eclipsefinance.core;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "net.sf.eclipsefinance.core";
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path
- *
- * @param path the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-}
Copied: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/CoreActivator.java (from rev 26, trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/Activator.java)
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/CoreActivator.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/CoreActivator.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,61 @@
+package net.sf.eclipsefinance.core;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class CoreActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "net.sf.eclipsefinance.core";
+
+ // The shared instance
+ private static CoreActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public CoreActivator() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static CoreActivator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ICollectionObserver.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ICollectionObserver.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ICollectionObserver.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ * Francois Cottet - adaptation for Eclipse Finance
+ */
+
+package net.sf.eclipsefinance.core;
+
+/**
+ */
+public interface ICollectionObserver
+{
+
+ public void itemAdded(Object o);
+
+ public void itemRemoved(Object o);
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ObservableList.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ObservableList.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ObservableList.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ * Francois Cottet - adaptation for Eclipse Finance
+ */
+package net.sf.eclipsefinance.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+/**
+ */
+public class ObservableList extends ArrayList
+{
+ private static final long serialVersionUID = 7282371672763711235L;
+ private List originalList;
+ private List observers = new ArrayList();
+
+ public ObservableList()
+ {
+ }
+
+ public ObservableList(List list)
+ {
+ super(list);
+ this.originalList = list;
+ }
+
+ public ObservableList(int initialCapacity)
+ {
+ super(initialCapacity);
+ }
+
+ public Collection getOriginalList()
+ {
+ return originalList;
+ }
+
+ public void addCollectionObserver(ICollectionObserver observer)
+ {
+ if (!observers.contains(observer))
+ observers.add(observer);
+ }
+
+ public void removeCollectionObserver(ICollectionObserver observer)
+ {
+ observers.remove(observer);
+ }
+
+ protected void notifyItemAdded(Object o)
+ {
+ Object[] obs = observers.toArray();
+ for (int i = 0; i < obs.length; i++)
+ ((ICollectionObserver)obs[i]).itemAdded(o);
+ }
+
+ protected void notifyItemRemoved(Object o)
+ {
+ Object[] obs = observers.toArray();
+ for (int i = 0; i < obs.length; i++)
+ ((ICollectionObserver)obs[i]).itemRemoved(o);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.ArrayList#add(java.lang.Object)
+ */
+ public boolean add(Object o)
+ {
+ boolean result = super.add(o);
+ if (originalList != null)
+ originalList.add(o);
+ notifyItemAdded(o);
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.ArrayList#add(int, java.lang.Object)
+ */
+ public void add(int index, Object element)
+ {
+ super.add(index, element);
+ if (originalList != null)
+ originalList.add(index, element);
+ notifyItemAdded(element);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.ArrayList#remove(java.lang.Object)
+ */
+ public boolean remove(Object o)
+ {
+ boolean result = super.remove(o);
+ if (originalList != null)
+ originalList.remove(o);
+ notifyItemRemoved(o);
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.ArrayList#remove(int)
+ */
+ public Object remove(int index)
+ {
+ Object result = super.remove(index);
+ if (originalList != null)
+ originalList.remove(index);
+ notifyItemRemoved(result);
+ return result;
+ }
+
+ public int countObservers()
+ {
+ return observers.size();
+ }
+}
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java 2006-09-20 17:59:38 UTC (rev 26)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -8,6 +8,7 @@
public class Account extends PlatformObject {
+ private Integer id = null;
private String name = null;
private Currency currency = null;
@@ -19,6 +20,11 @@
Account(String name){
this.name = name;
}
+
+ Account(int id, String name){
+ this.id = new Integer(id);
+ this.name = name;
+ }
public String getName() {
return name;
@@ -64,4 +70,12 @@
this.transactionList = transactionList;
}
+ public Integer getId() {
+ return this.id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/AccountGroup.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2004-2006 Marco Maccaferri and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ */
+
+package net.sf.eclipsefinance.core.model;
+
+import java.util.Iterator;
+
+import net.sf.eclipsefinance.core.ObservableList;
+import net.sf.eclipsefinance.core.persistence.PersistentObject;
+
+public class AccountGroup extends PersistentObject
+{
+ private AccountGroup parent;
+ private String description = "";
+ private ObservableList groups = new ObservableList();
+ private ObservableList accounts;
+
+ public AccountGroup()
+ {
+ }
+
+ public AccountGroup(Integer id)
+ {
+ super(id);
+ }
+
+ public AccountGroup getParent()
+ {
+ return parent;
+ }
+
+ public void setParent(AccountGroup parent)
+ {
+ this.parent = parent;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ setChanged();
+ }
+
+ public ObservableList getGroups()
+ {
+ return groups;
+ }
+
+ public void setGroups(ObservableList groups)
+ {
+ this.groups = groups;
+ }
+
+ public ObservableList getAccounts()
+ {
+ if (accounts == null)
+ {
+ accounts = new ObservableList();
+ if (getRepository() != null)
+ {
+ for (Iterator iter = getRepository().allAccounts().iterator(); iter.hasNext(); )
+ {
+ Account account = (Account) iter.next();
+ if (this.equals(account.getGroup()))
+ accounts.add(account);
+ }
+ }
+ }
+ return accounts;
+ }
+
+ public void setAccounts(ObservableList accounts)
+ {
+ this.accounts = accounts;
+ }
+}
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Bank.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Bank.java 2006-09-20 17:59:38 UTC (rev 26)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Bank.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -3,18 +3,22 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.PlatformObject;
-
-public class Bank extends PlatformObject {
+public class Bank extends AccountGroup {
+ private Integer id = null;
private String name = null;
- private List accountList = new ArrayList();
+ private List<Account> accountList = new ArrayList<Account>();
private Fortune fortune = null;
public Bank(String name){
this.name = name;
}
+ public Bank(int id, String name){
+ this.id = new Integer(id);
+ this.name = name;
+ }
+
public Fortune getFortune() {
return this.fortune;
}
@@ -23,9 +27,13 @@
this.fortune = fortune;
}
- public List getAccountList() {
+ public List<Account> getAccountList() {
return this.accountList;
}
+
+ public Account getAccount(Integer id) {
+ return this.accountList.get(0);
+ }
public String getName() {
return this.name;
@@ -44,5 +52,13 @@
this.accountList.remove(oldAccount);
oldAccount.setBank(null);
}
+
+ public Integer getId() {
+ return this.id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
}
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Fortune.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Fortune.java 2006-09-20 17:59:38 UTC (rev 26)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Fortune.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -10,7 +10,7 @@
private static Fortune instance = new Fortune();
private String name = null;
- private List bankList = new ArrayList();
+ private List<Bank> bankList = new ArrayList<Bank>();
private Fortune(){
init();
@@ -20,7 +20,7 @@
return instance;
}
- public List getBankList() {
+ public List<Bank> getBankList() {
return this.bankList;
}
@@ -28,8 +28,8 @@
* Loop tru te banks to find existing accounts
* @return list of all existing account
*/
- public List getAccountList() {
- List accountList = new ArrayList();
+ public List<Account> getAccountList() {
+ List<Account> accountList = new ArrayList<Account>();
Iterator bankIter = this.bankList.iterator();
while(bankIter.hasNext()){
Bank currentBank = (Bank)bankIter.next();
@@ -37,6 +37,16 @@
}
return accountList;
}
+
+ public Account getAccount(Integer id) {
+ Iterator bankIter = this.bankList.iterator();
+ while(bankIter.hasNext()){
+ Bank currentBank = (Bank)bankIter.next();
+ Account currentAccount = currentBank.getAccount(id);
+ if(currentAccount!=null) return currentAccount;
+ }
+ return null;
+ }
public String getName() {
return this.name;
@@ -58,23 +68,23 @@
private void init(){
//UBS
- Bank bank1 = new Bank("UBS");
+ Bank bank1 = new Bank(1, "UBS");
addBank(bank1);
- Account account1a = new Account("Compte courant");
+ Account account1a = new Account(101, "Compte courant");
bank1.addAccount(account1a);
- Account account1b = new Account("Compte epargne");
+ Account account1b = new Account(102, "Compte epargne");
bank1.addAccount(account1b);
//Banque postale
- Bank bank2 = new Bank("La Banque Postale");
+ Bank bank2 = new Bank(2, "La Banque Postale");
addBank(bank2);
- Account account2a = new Account("CCP");
+ Account account2a = new Account(201, "CCP");
bank2.addAccount(account2a);
- Account account2b = new Account("Compte titre ordinaire");
+ Account account2b = new Account(202, "Compte titre ordinaire");
bank2.addAccount(account2b);
//Boursorama
- Bank bank3 = new Bank("Boursorama");
+ Bank bank3 = new Bank(3, "Boursorama");
addBank(bank3);
}
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java 2006-09-20 17:59:38 UTC (rev 26)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -22,7 +22,7 @@
private Integer id;
private String memo = null;
private BigDecimal amount = new BigDecimal("0");
- Map params = new HashMap();
+ Map<String,String> params = new HashMap<String,String>();
public Transaction() {
}
@@ -73,7 +73,7 @@
return this.params;
}
- public void setParams(Map params) {
+ public void setParams(Map<String,String> params) {
this.params = params;
}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Account.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Account.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Account.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ * Francois Cottet - adaptation for Eclipse Finance
+ */
+
+package net.sf.eclipsefinance.core.persistence;
+
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Currency;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import net.sf.eclipsefinance.core.ICollectionObserver;
+import net.sf.eclipsefinance.core.ObservableList;
+
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+public abstract class Account extends PersistentObject implements Cloneable
+{
+ private String pluginId = "";
+ private String description = "";
+ private Currency currency = null;
+ private double initialBalance = 0;
+ private AccountGroup group = null;
+ private PersistentPreferenceStore preferenceStore = new PersistentPreferenceStore();
+ private ObservableList transactions = new ObservableList();
+ private ICollectionObserver transactionsObserver = new ICollectionObserver() {
+ public void itemAdded(Object o)
+ {
+ setChanged();
+ }
+
+ public void itemRemoved(Object o)
+ {
+ setChanged();
+ }
+ };
+ private IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event)
+ {
+ setChanged();
+ }
+ };
+
+ public Account()
+ {
+ transactions.addCollectionObserver(transactionsObserver);
+ preferenceStore.addPropertyChangeListener(propertyChangeListener);
+ }
+
+ public Account(Integer id)
+ {
+ super(id);
+ transactions.addCollectionObserver(transactionsObserver);
+ preferenceStore.addPropertyChangeListener(propertyChangeListener);
+ }
+
+ /**
+ * Creates a copy of the given account.
+ */
+ protected Account(Account account)
+ {
+ setDescription(account.getDescription());
+ setCurrency(account.getCurrency());
+ setInitialBalance(account.getBalance());
+ setGroup(account.getGroup());
+ setPreferenceStore(new PersistentPreferenceStore(account.getPreferenceStore()));
+ }
+
+ public String getPluginId()
+ {
+ return pluginId;
+ }
+
+ public void setPluginId(String serviceId)
+ {
+ Assert.isNotNull(serviceId);
+ this.pluginId = serviceId;
+ setChanged();
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ setChanged();
+ }
+
+ public Currency getCurrency()
+ {
+ return currency;
+ }
+
+ public void setCurrency(Currency currency)
+ {
+ this.currency = currency;
+ setChanged();
+ }
+
+ public double getInitialBalance()
+ {
+ return initialBalance;
+ }
+
+ public void setInitialBalance(double initbalance)
+ {
+ this.initialBalance = initbalance;
+ setChanged();
+ }
+
+ public AccountGroup getGroup()
+ {
+ return group;
+ }
+
+ public void setGroup(AccountGroup group)
+ {
+ this.group = group;
+ setChanged();
+ }
+
+ public PersistentPreferenceStore getPreferenceStore()
+ {
+ return preferenceStore;
+ }
+
+ public void setPreferenceStore(PersistentPreferenceStore preferenceStore)
+ {
+ Assert.isNotNull(preferenceStore);
+ this.preferenceStore.removePropertyChangeListener(propertyChangeListener);
+ this.preferenceStore = preferenceStore;
+ this.preferenceStore.addPropertyChangeListener(propertyChangeListener);
+ }
+
+ public ObservableList getTransactions()
+ {
+ return transactions;
+ }
+
+ public void setTransactions(List transactions)
+ {
+ Assert.isNotNull(transactions);
+ if (this.transactions != null)
+ this.transactions.removeCollectionObserver(transactionsObserver);
+ this.transactions = new ObservableList(transactions);
+ this.transactions.addCollectionObserver(transactionsObserver);
+ }
+
+ /**
+ * Gets the balance of the account
+ *
+ * @return the account's balance
+ */
+ public double getBalance()
+ {
+ double result = getInitialBalance();
+
+ Object[] objs = getTransactions().toArray();
+ for (int i = 0; i < objs.length; i++)
+ {
+ Transaction transaction = (Transaction)objs[i];
+ double amount = transaction.getAmount();
+ if (getCurrency() != null && !getCurrency().equals(transaction.getSecurity().getCurrency()))
+ amount = CurrencyConverter.getInstance().convert(transaction.getDate(), amount, transaction.getSecurity().getCurrency(), getCurrency());
+ result += amount;
+ }
+
+ return result;
+ }
+
+ /**
+ * Return the number of stocks held for the given security.
+ *
+ * @param security the security to search
+ * @return holded quantity
+ */
+ public int getPosition(Security security)
+ {
+ int result = 0;
+
+ Object[] objs = getTransactions().toArray();
+ for (int i = 0; i < objs.length; i++)
+ {
+ Transaction transaction = (Transaction)objs[i];
+ if (transaction.getSecurity().equals(security))
+ result += transaction.getQuantity();
+ }
+
+ return result;
+ }
+
+ public List getPortfolio()
+ {
+ List result = new ArrayList();
+
+ Map map = new HashMap();
+ for (Iterator iter2 = getTransactions().iterator(); iter2.hasNext(); )
+ {
+ Transaction transaction = (Transaction)iter2.next();
+ PortfolioPosition position = (PortfolioPosition)map.get(transaction.getSecurity());
+ if (position == null)
+ map.put(transaction.getSecurity(), new PortfolioPosition(this, transaction.getSecurity(), transaction.getQuantity(), transaction.getAmount()));
+ else
+ position.add(transaction.getQuantity(), transaction.getAmount());
+ }
+
+ List list = new ArrayList(map.keySet());
+ Collections.sort(list, new Comparator() {
+ public int compare(Object arg0, Object arg1)
+ {
+ return ((Security)arg0).getDescription().compareTo(((Security)arg1).getDescription());
+ }
+ });
+ for (Iterator iter = list.iterator(); iter.hasNext(); )
+ {
+ Security security = (Security)iter.next();
+ PortfolioPosition position = (PortfolioPosition)map.get(security);
+ if (position.getQuantity() != 0)
+ result.add(position);
+ }
+
+ return result;
+ }
+
+ public PortfolioPosition getPortfolio(Security security)
+ {
+ PortfolioPosition position = new PortfolioPosition(this, security, 0, 0);
+
+ for (Iterator iter2 = getTransactions().iterator(); iter2.hasNext(); )
+ {
+ Transaction transaction = (Transaction)iter2.next();
+ if (position.getSecurity().equals(transaction.getSecurity()))
+ position.add(transaction.getQuantity(), transaction.getAmount());
+ }
+
+ return position;
+ }
+
+ public double getExpenses(Security security, int quantity, double price)
+ {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException
+ {
+ throw new CloneNotSupportedException();
+ }
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/AccountGroup.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/AccountGroup.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/AccountGroup.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ * Francois Cottet - adaptation for Eclipse Finance
+ */
+
+package net.sf.eclipsefinance.core.persistence;
+
+import java.util.Iterator;
+
+import net.sourceforge.eclipsetrader.core.ObservableList;
+
+public class AccountGroup extends PersistentObject
+{
+ private AccountGroup parent;
+ private String description = "";
+ private ObservableList groups = new ObservableList();
+ private ObservableList accounts;
+
+ public AccountGroup()
+ {
+ }
+
+ public AccountGroup(Integer id)
+ {
+ super(id);
+ }
+
+ public AccountGroup getParent()
+ {
+ return parent;
+ }
+
+ public void setParent(AccountGroup parent)
+ {
+ this.parent = parent;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ setChanged();
+ }
+
+ public ObservableList getGroups()
+ {
+ return groups;
+ }
+
+ public void setGroups(ObservableList groups)
+ {
+ this.groups = groups;
+ }
+
+ public ObservableList getAccounts()
+ {
+ if (accounts == null)
+ {
+ accounts = new ObservableList();
+ if (getRepository() != null)
+ {
+ for (Iterator iter = getRepository().allAccounts().iterator(); iter.hasNext(); )
+ {
+ Account account = (Account) iter.next();
+ if (this.equals(account.getGroup()))
+ accounts.add(account);
+ }
+ }
+ }
+ return accounts;
+ }
+
+ public void setAccounts(ObservableList accounts)
+ {
+ this.accounts = accounts;
+ }
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/PersistentObject.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/PersistentObject.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/PersistentObject.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ * Francois Cottet - adaptation for Eclipse Finance
+ */
+
+package net.sf.eclipsefinance.core.persistence;
+
+import java.util.Observable;
+
+/**
+ * Base abstract class for all persistent object classes.
+ */
+public abstract class PersistentObject extends Observable
+{
+ private Integer id;
+ private Object data;
+ private Repository repository;
+
+ public PersistentObject()
+ {
+ }
+
+ public PersistentObject(Integer id)
+ {
+ this.id = id;
+ }
+
+ public Integer getId()
+ {
+ return id;
+ }
+
+ public void setId(Integer id)
+ {
+ this.id = id;
+ }
+
+ public Object getData()
+ {
+ return data;
+ }
+
+ public void setData(Object data)
+ {
+ this.data = data;
+ }
+
+ public Repository getRepository()
+ {
+ return repository;
+ }
+
+ public void setRepository(Repository repository)
+ {
+ this.repository = repository;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Observable#setChanged()
+ */
+ public synchronized void setChanged()
+ {
+ super.setChanged();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Observable#clearChanged()
+ */
+ public synchronized void clearChanged()
+ {
+ super.clearChanged();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj == null || !this.getClass().getName().equals(obj.getClass().getName()))
+ return false;
+ PersistentObject that = (PersistentObject)obj;
+ if (this.getId() == null || that.getId() == null)
+ return false;
+ return this.getId().equals(that.getId());
+ }
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/PersistentPreferenceStore.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/PersistentPreferenceStore.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/PersistentPreferenceStore.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,601 @@
+/*
+ * Copyright (c) 2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ * Francois Cottet - adaptation for Eclipse Finance
+ */
+
+package net.sf.eclipsefinance.core.persistence;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.util.SafeRunnable;
+
+/**
+ * A concrete preference store implementation based on an internal
+ * <code>java.util.Map</code> object.
+ * <p>
+ * This class was not designed to be subclassed.
+ * </p>
+ *
+ * @see IPreferenceStore
+ */
+public class PersistentPreferenceStore implements IPreferenceStore
+{
+ /**
+ * List of registered listeners (element type:
+ * <code>IPropertyChangeListener</code>). These listeners are to be
+ * informed when the current value of a preference changes.
+ */
+ private ListenerList listeners = new ListenerList();
+
+ /**
+ * The mapping from preference name to preference value (represented as
+ * strings).
+ */
+ private Map properties = new HashMap();
+
+ /**
+ * The mapping from preference name to default preference value (represented
+ * as strings).
+ */
+ private Map defaultProperties = new HashMap();
+
+ /**
+ * Indicates whether a value as been changed by <code>setToDefault</code>
+ * or <code>setValue</code>; initially <code>false</code>.
+ */
+ private boolean dirty = false;
+
+ /**
+ * Creates an empty preference store.
+ */
+ public PersistentPreferenceStore()
+ {
+ }
+
+ /**
+ * Creates an preference store that is the exact copy of the given preference store.
+ */
+ public PersistentPreferenceStore(PersistentPreferenceStore preferenceStore)
+ {
+ properties.putAll(preferenceStore.properties);
+ defaultProperties.putAll(preferenceStore.defaultProperties);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener)
+ {
+ listeners.add(listener);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public boolean contains(String name)
+ {
+ return (properties.containsKey(name) || defaultProperties.containsKey(name));
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void firePropertyChangeEvent(String name, Object oldValue, Object newValue)
+ {
+ final Object[] finalListeners = this.listeners.getListeners();
+ // Do we need to fire an event.
+ if (finalListeners.length > 0 && (oldValue == null || !oldValue.equals(newValue)))
+ {
+ final PropertyChangeEvent pe = new PropertyChangeEvent(this, name, oldValue, newValue);
+ for (int i = 0; i < finalListeners.length; ++i)
+ {
+ final IPropertyChangeListener l = (IPropertyChangeListener) finalListeners[i];
+ SafeRunnable.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
+ public void run()
+ {
+ l.propertyChange(pe);
+ }
+ });
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public boolean getBoolean(String name)
+ {
+ return getBoolean(properties, name);
+ }
+
+ /**
+ * Helper function: gets boolean for a given name.
+ *
+ * @param p
+ * @param name
+ * @return boolean
+ */
+ private boolean getBoolean(Map p, String name)
+ {
+ String value = (String)p.get(name);
+ if (value == null)
+ return BOOLEAN_DEFAULT_DEFAULT;
+ if (value.equals(IPreferenceStore.TRUE))
+ return true;
+ return false;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public boolean getDefaultBoolean(String name)
+ {
+ return getBoolean(defaultProperties, name);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public double getDefaultDouble(String name)
+ {
+ return getDouble(defaultProperties, name);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public float getDefaultFloat(String name)
+ {
+ return getFloat(defaultProperties, name);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public int getDefaultInt(String name)
+ {
+ return getInt(defaultProperties, name);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public long getDefaultLong(String name)
+ {
+ return getLong(defaultProperties, name);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public String getDefaultString(String name)
+ {
+ return getString(defaultProperties, name);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public double getDouble(String name)
+ {
+ return getDouble(properties, name);
+ }
+
+ /**
+ * Helper function: gets double for a given name.
+ *
+ * @param p
+ * @param name
+ * @return double
+ */
+ private double getDouble(Map p, String name)
+ {
+ String value = (String)p.get(name);
+ if (value == null)
+ return DOUBLE_DEFAULT_DEFAULT;
+ double ival = DOUBLE_DEFAULT_DEFAULT;
+ try
+ {
+ ival = new Double(value).doubleValue();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ return ival;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public float getFloat(String name)
+ {
+ return getFloat(properties, name);
+ }
+
+ /**
+ * Helper function: gets float for a given name.
+ * @param p
+ * @param name
+ * @return float
+ */
+ private float getFloat(Map p, String name)
+ {
+ String value = (String)p.get(name);
+ if (value == null)
+ return FLOAT_DEFAULT_DEFAULT;
+ float ival = FLOAT_DEFAULT_DEFAULT;
+ try
+ {
+ ival = new Float(value).floatValue();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ return ival;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public int getInt(String name)
+ {
+ return getInt(properties, name);
+ }
+
+ /**
+ * Helper function: gets int for a given name.
+ * @param p
+ * @param name
+ * @return int
+ */
+ private int getInt(Map p, String name)
+ {
+ String value = (String)p.get(name);
+ if (value == null)
+ return INT_DEFAULT_DEFAULT;
+ int ival = 0;
+ try
+ {
+ ival = Integer.parseInt(value);
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ return ival;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public long getLong(String name)
+ {
+ return getLong(properties, name);
+ }
+
+ /**
+ * Helper function: gets long for a given name.
+ * @param p
+ * @param name
+ * @return
+ */
+ private long getLong(Map p, String name)
+ {
+ String value = (String)p.get(name);
+ if (value == null)
+ return LONG_DEFAULT_DEFAULT;
+ long ival = LONG_DEFAULT_DEFAULT;
+ try
+ {
+ ival = Long.parseLong(value);
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ return ival;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public String getString(String name)
+ {
+ return getString(properties, name);
+ }
+
+ /**
+ * Helper function: gets string for a given name.
+ * @param p
+ * @param name
+ * @return
+ */
+ private String getString(Map p, String name)
+ {
+ String value = (String)p.get(name);
+ if (value == null)
+ return STRING_DEFAULT_DEFAULT;
+ return value;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public boolean isDefault(String name)
+ {
+ return (!properties.containsKey(name) && defaultProperties.containsKey(name));
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public boolean needsSaving()
+ {
+ return dirty;
+ }
+
+ /**
+ * Returns an enumeration of all preferences known to this store which have
+ * current values other than their default value.
+ *
+ * @return an array of preference names
+ */
+ public String[] preferenceNames()
+ {
+ ArrayList list = new ArrayList();
+ Iterator it = properties.keySet().iterator();
+ while (it.hasNext())
+ {
+ list.add(it.next());
+ }
+ return (String[]) list.toArray(new String[list.size()]);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void putValue(String name, String value)
+ {
+ String oldValue = getString(name);
+ if (oldValue == null || !oldValue.equals(value))
+ {
+ setValue(properties, name, value);
+ dirty = true;
+ }
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener)
+ {
+ listeners.remove(listener);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setDefault(String name, double value)
+ {
+ setValue(defaultProperties, name, value);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setDefault(String name, float value)
+ {
+ setValue(defaultProperties, name, value);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setDefault(String name, int value)
+ {
+ setValue(defaultProperties, name, value);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setDefault(String name, long value)
+ {
+ setValue(defaultProperties, name, value);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setDefault(String name, String value)
+ {
+ setValue(defaultProperties, name, value);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setDefault(String name, boolean value)
+ {
+ setValue(defaultProperties, name, value);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setToDefault(String name)
+ {
+ Object oldValue = properties.get(name);
+ properties.remove(name);
+ dirty = true;
+ Object newValue = null;
+ if (defaultProperties != null)
+ newValue = defaultProperties.get(name);
+ firePropertyChangeEvent(name, oldValue, newValue);
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setValue(String name, double value)
+ {
+ double oldValue = getDouble(name);
+ if (oldValue != value)
+ {
+ setValue(properties, name, value);
+ dirty = true;
+ firePropertyChangeEvent(name, new Double(oldValue), new Double(value));
+ }
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setValue(String name, float value)
+ {
+ float oldValue = getFloat(name);
+ if (oldValue != value)
+ {
+ setValue(properties, name, value);
+ dirty = true;
+ firePropertyChangeEvent(name, new Float(oldValue), new Float(value));
+ }
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setValue(String name, int value)
+ {
+ int oldValue = getInt(name);
+ if (oldValue != value)
+ {
+ setValue(properties, name, value);
+ dirty = true;
+ firePropertyChangeEvent(name, new Integer(oldValue), new Integer(value));
+ }
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setValue(String name, long value)
+ {
+ long oldValue = getLong(name);
+ if (oldValue != value)
+ {
+ setValue(properties, name, value);
+ dirty = true;
+ firePropertyChangeEvent(name, new Long(oldValue), new Long(value));
+ }
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setValue(String name, String value)
+ {
+ String oldValue = getString(name);
+ if (oldValue == null || !oldValue.equals(value))
+ {
+ setValue(properties, name, value);
+ dirty = true;
+ firePropertyChangeEvent(name, oldValue, value);
+ }
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IPreferenceStore.
+ */
+ public void setValue(String name, boolean value)
+ {
+ boolean oldValue = getBoolean(name);
+ if (oldValue != value)
+ {
+ setValue(properties, name, value);
+ dirty = true;
+ firePropertyChangeEvent(name, new Boolean(oldValue), new Boolean(value));
+ }
+ }
+
+ /**
+ * Helper method: sets value for a given name.
+ * @param p
+ * @param name
+ * @param value
+ */
+ private void setValue(Map p, String name, double value)
+ {
+ p.put(name, Double.toString(value));
+ }
+
+ /**
+ * Helper method: sets value for a given name.
+ * @param p
+ * @param name
+ * @param value
+ */
+ private void setValue(Map p, String name, float value)
+ {
+ p.put(name, Float.toString(value));
+ }
+
+ /**
+ * Helper method: sets value for a given name.
+ * @param p
+ * @param name
+ * @param value
+ */
+ private void setValue(Map p, String name, int value)
+ {
+ p.put(name, Integer.toString(value));
+ }
+
+ /**
+ * Helper method: sets the value for a given name.
+ * @param p
+ * @param name
+ * @param value
+ */
+ private void setValue(Map p, String name, long value)
+ {
+ p.put(name, Long.toString(value));
+ }
+
+ /**
+ * Helper method: sets the value for a given name.
+ * @param p
+ * @param name
+ * @param value
+ */
+ private void setValue(Map p, String name, String value)
+ {
+ Assert.isTrue(value != null);
+ p.put(name, value);
+ }
+
+ /**
+ * Helper method: sets the value for a given name.
+ * @param p
+ * @param name
+ * @param value
+ */
+ private void setValue(Map p, String name, boolean value)
+ {
+ p.put(name, value == true ? IPreferenceStore.TRUE : IPreferenceStore.FALSE);
+ }
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Repository.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Repository.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Repository.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2004-2006 Marco Maccaferri and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ */
+
+package net.sf.eclipsefinance.core.persistence;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Observable;
+
+import net.sf.eclipsefinance.core.ObservableList;
+import net.sourceforge.eclipsetrader.core.db.Account;
+import net.sourceforge.eclipsetrader.core.db.AccountGroup;
+import net.sourceforge.eclipsetrader.core.db.Chart;
+import net.sourceforge.eclipsetrader.core.db.Event;
+import net.sourceforge.eclipsetrader.core.db.NewsItem;
+import net.sourceforge.eclipsetrader.core.db.Order;
+import net.sourceforge.eclipsetrader.core.db.PersistentObject;
+import net.sourceforge.eclipsetrader.core.db.Security;
+import net.sourceforge.eclipsetrader.core.db.SecurityGroup;
+import net.sourceforge.eclipsetrader.core.db.Watchlist;
+import net.sourceforge.eclipsetrader.core.db.WatchlistItem;
+import net.sourceforge.eclipsetrader.core.db.trading.TradingSystem;
+
+
+/**
+ */
+public class Repository
+{
+ private ObservableList accounts;
+ private ObservableList accountGroups;
+ private Map newsMap = new HashMap();
+
+ public Repository()
+ {
+ }
+
+ /**
+ * Disposes the resources associated with the receiver.
+ */
+ public void dispose()
+ {
+ }
+
+ /**
+ * Removes all contents from the receiver.
+ */
+ public void clear()
+ {
+ accounts = null;
+ accountGroups = null;
+ }
+
+
+ public ObservableList allAccounts()
+ {
+ if (accounts == null)
+ accounts = new ObservableList();
+ return accounts;
+ }
+
+ public ObservableList allAccountGroups()
+ {
+ if (accountGroups == null)
+ accountGroups = new ObservableList();
+ return accountGroups;
+ }
+
+
+
+ public PersistentObject load(Class clazz, Integer id)
+ {
+// if (clazz.equals(Security.class))
+// {
+// for (Iterator iter = allSecurities().iterator(); iter.hasNext(); )
+// {
+// PersistentObject obj = (PersistentObject)iter.next();
+// if (id.equals(obj.getId()))
+// return obj;
+// }
+// }
+
+ return null;
+ }
+
+ public void save(PersistentObject obj)
+ {
+ obj.setRepository(this);
+ if (obj instanceof Observable)
+ ((Observable)obj).notifyObservers();
+
+// if (obj instanceof Security)
+// {
+// if (!allSecurities().contains(obj))
+// allSecurities().add(obj);
+// }
+
+
+
+ if (obj instanceof AccountGroup)
+ {
+ AccountGroup group = (AccountGroup)obj;
+ if (!allAccountGroups().contains(group))
+ allAccountGroups().add(group);
+ if (group.getParent() != null)
+ {
+ AccountGroup parent = group.getParent();
+ if (!parent.getGroups().contains(group))
+ parent.getGroups().add(group);
+ }
+ }
+ if (obj instanceof Account)
+ {
+ Account account = (Account)obj;
+ if (!allAccounts().contains(account))
+ allAccounts().add(account);
+ if (account.getGroup() != null)
+ {
+ AccountGroup group = account.getGroup();
+ if (!group.getAccounts().contains(account))
+ group.getAccounts().add(account);
+ }
+ }
+
+
+ }
+
+ public void delete(PersistentObject obj)
+ {
+
+ if (obj instanceof Account)
+ {
+ TradingSystem[] systems = (TradingSystem[])getTradingSystems().toArray(new TradingSystem[0]);
+ for (int i = 0; i < systems.length; i++)
+ {
+ if (obj.equals(systems[i].getAccount()))
+ delete(systems[i]);
+ }
+
+ allAccounts().remove(obj);
+ if (((Account)obj).getGroup() != null)
+ ((Account)obj).getGroup().getAccounts().remove(obj);
+ }
+
+ if (obj instanceof AccountGroup)
+ {
+ AccountGroup group = (AccountGroup)obj;
+
+ Object[] accounts = group.getAccounts().toArray();
+ for (int i = 0; i < accounts.length; i++)
+ delete((Account)accounts[i]);
+
+ Object[] groups = group.getAccounts().toArray();
+ for (int i = 0; i < groups.length; i++)
+ delete((AccountGroup)groups[i]);
+
+ if (group.getParent() != null)
+ group.getParent().getGroups().remove(group);
+
+ allAccountGroups().remove(group);
+ }
+ }
+
+ public List loadHistory(Integer id)
+ {
+ return new ArrayList();
+ }
+
+ public void saveHistory(Integer id, List list)
+ {
+ }
+
+
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Transaction.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Transaction.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/persistence/Transaction.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ * Francois Cottet - adaptation for Eclipse Finance
+ */
+package net.sf.eclipsefinance.core.persistence;
+
+import java.math.BigDecimal;
+import java.security.Security;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Transaction extends PersistentObject
+{
+ private Date date;
+ private String memo = null;
+ private BigDecimal amount = new BigDecimal("0");
+ Map params = new HashMap();
+
+ public Transaction()
+ {
+ }
+
+ public Transaction(Integer id)
+ {
+ super(id);
+ }
+
+ public Transaction(Date date, String memo, BigDecimal amount)
+ {
+ this.date = date;
+ }
+
+ public Date getDate()
+ {
+ return date;
+ }
+
+ public void setDate(Date date)
+ {
+ this.date = date;
+ setChanged();
+ }
+
+ public BigDecimal getAmount()
+ {
+ return this.amount;
+ }
+
+ public void setAmount(BigDecimal amount)
+ {
+ this.amount = amount;
+ setChanged();
+ }
+ public void setAmount(double amount)
+ {
+ this.amount = new BigDecimal(amount);
+ setChanged();
+ }
+
+ public Map getParams()
+ {
+ return params;
+ }
+
+ public void setParams(Map params)
+ {
+ this.params = params;
+ }
+
+ public void setParam(String key, String value)
+ {
+ params.put(key, value);
+ }
+
+ public String getParam(String key)
+ {
+ return (String)params.get(key);
+ }
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountSelection.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountSelection.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/AccountSelection.java 2006-09-21 12:01:54 UTC (rev 27)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Cottet - initial API and implementation
+ */
+
+package net.sf.eclipsefinance.core.ui;
+
+import net.sf.eclipsefinance.core.model.Account;
+
+public class AccountSelection extends BankSelection
+{
+ private Account account;
+
+ public AccountSelection(Account account)
+ {
+ super(account.getBank());
+ this.account = account;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelection#isEmpty()
+ */
+ public boolean isEmpty()
+ {
+ return (account == null);
+ }
+
+ public Account getAccount()
+ {
+ return account;
+ }
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/BankSelection.java
================================================...
[truncated message content] |
|
From: <yu...@us...> - 2006-09-20 17:59:46
|
Revision: 26
http://svn.sourceforge.net/eclipsefinance/?rev=26&view=rev
Author: yukio7
Date: 2006-09-20 10:59:38 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
work in progress
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/META-INF/MANIFEST.MF
trunk/net.sf.eclipsefinance.core/plugin.xml
Modified: trunk/net.sf.eclipsefinance.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/net.sf.eclipsefinance.core/META-INF/MANIFEST.MF 2006-09-20 17:59:21 UTC (rev 25)
+++ trunk/net.sf.eclipsefinance.core/META-INF/MANIFEST.MF 2006-09-20 17:59:38 UTC (rev 26)
@@ -6,5 +6,7 @@
Bundle-Activator: net.sf.eclipsefinance.core.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime
+ org.eclipse.core.runtime,
+ org.eclipse.ui.views,
+ org.eclipse.ui.views.properties.tabbed
Eclipse-LazyStart: true
Modified: trunk/net.sf.eclipsefinance.core/plugin.xml
===================================================================
--- trunk/net.sf.eclipsefinance.core/plugin.xml 2006-09-20 17:59:21 UTC (rev 25)
+++ trunk/net.sf.eclipsefinance.core/plugin.xml 2006-09-20 17:59:38 UTC (rev 26)
@@ -5,7 +5,7 @@
point="org.eclipse.ui.perspectives">
<perspective
name="Account"
- class="net.sf.eclipsefinance.core.views.CorePerspective"
+ class="net.sf.eclipsefinance.core.ui.views.CorePerspective"
id="net.sf.eclipsefinance.core.views.CorePerspective">
</perspective>
</extension>
@@ -18,11 +18,17 @@
<view
allowMultiple="false"
category="net.sf.eclipsefinance.core"
- class="net.sf.eclipsefinance.core.views.AccountView"
+ class="net.sf.eclipsefinance.core.ui.views.AccountView"
icon="icons/sample.gif"
- id="net.sf.eclipsefinance.core.views.AccountView"
+ id="net.sf.eclipsefinance.core.ui.views.AccountView"
name="Account View">
- </view>
+ </view>
+ <view
+ category="net.sf.eclipsefinance.core"
+ class="net.sf.eclipsefinance.core.ui.view.TransactionsView"
+ icon="icons/sample.gif"
+ id="net.sf.eclipsefinance.core.ui.view.TransactionsView"
+ name="Transactions View"/>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 17:59:28
|
Revision: 25
http://svn.sourceforge.net/eclipsefinance/?rev=25&view=rev
Author: yukio7
Date: 2006-09-20 10:59:21 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
work in progress
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java 2006-09-20 17:55:36 UTC (rev 24)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java 2006-09-20 17:59:21 UTC (rev 25)
@@ -20,6 +20,7 @@
import net.sf.eclipsefinance.core.model.Account;
import net.sf.eclipsefinance.core.model.Transaction;
+import net.sf.eclipsefinance.core.ui.dialogs.TransactionDialog;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -49,9 +50,9 @@
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.part.PageBookView.SelectionProvider;
-public class TransactionsView extends ViewPart implements ICollectionObserver
+public class TransactionsView extends ViewPart
{
- public static final String VIEW_ID = "net.sourceforge.eclipsetrader.views.transactions";
+ public static final String VIEW_ID = "net.sf.eclipsefinance.core.ui.views.TransactionView";
private Account account;
private Table table;
private Color evenForeground = new Color(null, 0, 0, 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 17:55:46
|
Revision: 24
http://svn.sourceforge.net/eclipsefinance/?rev=24&view=rev
Author: yukio7
Date: 2006-09-20 10:55:36 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
fix: using new Fortune
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountView.java
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountView.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountView.java 2006-09-20 17:55:07 UTC (rev 23)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountView.java 2006-09-20 17:55:36 UTC (rev 24)
@@ -16,10 +16,10 @@
public class AccountView extends ViewPart {
- public static final String ID = "net.sf.eclipsefinance.core.views.AccountView";
+ public static final String ID = "net.sf.eclipsefinance.core.ui.views.AccountView";
private TreeViewer viewer;
- private Fortune fortune = new Fortune();
+ private Fortune fortune = Fortune.getInstance();
private IAdapterFactory adapterFactory = new CoreFinanceAdapterFactory();
public void createPartControl(Composite parent){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 17:55:24
|
Revision: 23
http://svn.sourceforge.net/eclipsefinance/?rev=23&view=rev
Author: yukio7
Date: 2006-09-20 10:55:07 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
fix: simple dialog with only an amount
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/TransactionDialog.java
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/TransactionDialog.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/TransactionDialog.java 2006-09-20 17:54:35 UTC (rev 22)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/TransactionDialog.java 2006-09-20 17:55:07 UTC (rev 23)
@@ -1,16 +1,17 @@
/*
- * Copyright (c) 2004-2006 Marco Maccaferri and others.
+ * Copyright (c) 2004-2006 Eclipse Finance.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Marco Maccaferri - initial API and implementation
+ * Francois Cottet - initial API and implementation
*/
package net.sf.eclipsefinance.core.ui.dialogs;
+import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -20,10 +21,9 @@
import java.util.Iterator;
import java.util.List;
-import net.sourceforge.eclipsetrader.core.CorePlugin;
-import net.sourceforge.eclipsetrader.core.db.Account;
-import net.sourceforge.eclipsetrader.core.db.Security;
-import net.sourceforge.eclipsetrader.core.db.Transaction;
+import net.sf.eclipsefinance.core.model.Account;
+import net.sf.eclipsefinance.core.model.Fortune;
+import net.sf.eclipsefinance.core.model.Transaction;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
@@ -36,7 +36,6 @@
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -48,17 +47,10 @@
public class TransactionDialog extends TitleAreaDialog
{
Account account;
- Security security;
- int defaultQuantity = 1;
Transaction transaction;
Text dateText;
Combo accountCombo;
- Combo securityCombo;
- Button buyButton;
- Button sellButton;
- Spinner quantitySpinner;
- Spinner priceSpinner;
- Spinner expensesSpinner;
+ Spinner amountSpinner;
Text totalText;
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
NumberFormat nf = NumberFormat.getInstance();
@@ -122,157 +114,53 @@
});
label = new Label(content, SWT.NONE);
- label.setText("Security");
+ label.setText("Amount");
label.setLayoutData(new GridData(125, SWT.DEFAULT));
- securityCombo = new Combo(content, SWT.READ_ONLY);
- securityCombo.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
- securityCombo.setVisibleItemCount(25);
- securityCombo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e)
- {
- Security security = (Security)securityCombo.getData(securityCombo.getText());
- if (security != null && security.getQuote() != null)
- {
- priceSpinner.setSelection((int)Math.round(security.getQuote().getLast() * Math.pow(10, priceSpinner.getDigits())));
- updateTotals();
- }
- }
- });
+ amountSpinner = new Spinner(content, SWT.BORDER);
+ amountSpinner.setMinimum(0);
+ amountSpinner.setMaximum(99999999);
+ amountSpinner.setDigits(2);
+ amountSpinner.setIncrement(1);
+ amountSpinner.setSelection(0);
+ amountSpinner.setLayoutData(new GridData(60, SWT.DEFAULT));
label = new Label(content, SWT.NONE);
- label.setLayoutData(new GridData(125, SWT.DEFAULT));
- Composite group = new Composite(content, SWT.NONE);
- gridLayout = new GridLayout(2, false);
- gridLayout.marginWidth = gridLayout.marginHeight = 0;
- group.setLayout(gridLayout);
- buyButton = new Button(group, SWT.RADIO);
- buyButton.setText("Buy");
- buyButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e)
- {
- updateTotals();
- }
- });
- sellButton = new Button(group, SWT.RADIO);
- sellButton.setText("Sell");
- sellButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e)
- {
- updateTotals();
- }
- });
-
- label = new Label(content, SWT.NONE);
- label.setText("Quantity");
- label.setLayoutData(new GridData(125, SWT.DEFAULT));
- quantitySpinner = new Spinner(content, SWT.BORDER);
- quantitySpinner.setMinimum(1);
- quantitySpinner.setMaximum(999999);
- quantitySpinner.setSelection(Math.abs(defaultQuantity));
- quantitySpinner.setLayoutData(new GridData(60, SWT.DEFAULT));
- quantitySpinner.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e)
- {
- updateTotals();
- }
- });
-
- label = new Label(content, SWT.NONE);
- label.setText("Price");
- label.setLayoutData(new GridData(125, SWT.DEFAULT));
- priceSpinner = new Spinner(content, SWT.BORDER);
- priceSpinner.setMinimum(0);
- priceSpinner.setMaximum(999999999);
- priceSpinner.setDigits(4);
- priceSpinner.setIncrement(100);
- priceSpinner.setSelection(0);
- priceSpinner.setLayoutData(new GridData(60, SWT.DEFAULT));
- priceSpinner.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e)
- {
- updateTotals();
- }
- });
-
- label = new Label(content, SWT.NONE);
- label.setText("Expenses");
- label.setLayoutData(new GridData(125, SWT.DEFAULT));
- expensesSpinner = new Spinner(content, SWT.BORDER);
- expensesSpinner.setMinimum(0);
- expensesSpinner.setMaximum(99999999);
- expensesSpinner.setDigits(2);
- expensesSpinner.setIncrement(1);
- expensesSpinner.setSelection(0);
- expensesSpinner.setLayoutData(new GridData(60, SWT.DEFAULT));
-
- label = new Label(content, SWT.NONE);
label.setText("Total");
label.setLayoutData(new GridData(125, SWT.DEFAULT));
totalText = new Text(content, SWT.BORDER|SWT.READ_ONLY|SWT.RIGHT);
totalText.setEnabled(false);
totalText.setLayoutData(new GridData(60, SWT.DEFAULT));
- List list = CorePlugin.getRepository().allAccounts();
+ List list = Fortune.getInstance().getAccountList();
Collections.sort(list, new Comparator() {
public int compare(Object arg0, Object arg1)
{
- return ((Account)arg0).getDescription().compareTo(((Account)arg1).getDescription());
+ return ((Account)arg0).getName().compareTo(((Account)arg1).getName());
}
});
for (Iterator iter = list.iterator(); iter.hasNext(); )
{
Account s = (Account)iter.next();
- accountCombo.add(s.getDescription());
- accountCombo.setData(s.getDescription(), s);
+ accountCombo.add(s.getName());
+ accountCombo.setData(s.getName(), s);
}
if (account != null)
- accountCombo.setText(account.getDescription());
+ accountCombo.setText(account.getName());
- list = CorePlugin.getRepository().allSecurities();
- Collections.sort(list, new Comparator() {
- public int compare(Object arg0, Object arg1)
- {
- return ((Security)arg0).getDescription().compareTo(((Security)arg1).getDescription());
- }
- });
- for (Iterator iter = list.iterator(); iter.hasNext(); )
- {
- Security s = (Security)iter.next();
- securityCombo.add(s.getDescription());
- securityCombo.setData(s.getDescription(), s);
- }
-
if (transaction != null)
{
setTitle("Edit a Transaction");
setMessage("Enter the details of the transaction to edit");
dateText.setText(df.format(transaction.getDate()));
- securityCombo.setText(transaction.getSecurity().getDescription());
- buyButton.setSelection(transaction.getQuantity() >= 0);
- sellButton.setSelection(transaction.getQuantity() < 0);
- quantitySpinner.setSelection(Math.abs(transaction.getQuantity()));
- priceSpinner.setSelection((int)Math.round(transaction.getPrice() * Math.pow(10, priceSpinner.getDigits())));
- expensesSpinner.setSelection((int)Math.round(transaction.getExpenses() * Math.pow(10, expensesSpinner.getDigits())));
+ amountSpinner.setSelection((int)Math.round(transaction.getAmount().doubleValue() * Math.pow(10, amountSpinner.getDigits())));
}
else
{
setTitle("Create a new Transaction");
setMessage("Enter the details of the transaction to create");
dateText.setText(df.format(Calendar.getInstance().getTime()));
- buyButton.setSelection(defaultQuantity >= 0);
- sellButton.setSelection(defaultQuantity < 0);
}
- if (security != null)
- {
- securityCombo.setText(security.getDescription());
- if (security.getQuote() != null)
- priceSpinner.setSelection((int)Math.round(security.getQuote().getLast() * Math.pow(10, priceSpinner.getDigits())));
- quantitySpinner.setFocus();
- }
- else
- securityCombo.setFocus();
-
updateTotals();
dateText.addModifyListener(new ModifyListener() {
@@ -298,18 +186,10 @@
public int open(Transaction transaction)
{
this.transaction = transaction;
- this.security = transaction.getSecurity();
return super.open();
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#open()
- */
- public int open(Security security)
- {
- this.security = security;
- return super.open();
- }
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
@@ -317,50 +197,31 @@
protected void okPressed()
{
if (transaction != null)
- account.getTransactions().remove(transaction);
+ account.getTransactionList().remove(transaction);
transaction = new Transaction();
transaction.setDate(Calendar.getInstance().getTime());
try {
transaction.setDate(df.parse(dateText.getText()));
} catch(Exception e) {
- CorePlugin.logException(e);
+// CorePlugin.logException(e);
+ e.printStackTrace();
}
- transaction.setSecurity((Security)securityCombo.getData(securityCombo.getText()));
- if (buyButton.getSelection())
- transaction.setQuantity(quantitySpinner.getSelection());
- else
- transaction.setQuantity(-quantitySpinner.getSelection());
- transaction.setPrice(priceSpinner.getSelection() / Math.pow(10, priceSpinner.getDigits()));
- transaction.setExpenses(expensesSpinner.getSelection() / Math.pow(10, expensesSpinner.getDigits()));
+ transaction.setAmount(amountSpinner.getSelection() / Math.pow(10, amountSpinner.getDigits()));
- account.getTransactions().add(transaction);
- CorePlugin.getRepository().save(account);
-
+ account.getTransactionList().add(transaction);
+
super.okPressed();
}
void updateTotals()
{
- int quantity = quantitySpinner.getSelection();
- double price = priceSpinner.getSelection() / Math.pow(10, priceSpinner.getDigits());
- double total = quantity * price;
-
- double expenses = account.getExpenses(security, quantity, price);
- if (transaction != null)
- expenses = transaction.getExpenses();
+ BigDecimal amount = new BigDecimal("0");
+ if (transaction != null)
+ amount = transaction.getAmount();
else
- expensesSpinner.setSelection((int)Math.round(expenses * Math.pow(10, expensesSpinner.getDigits())));
- if (buyButton.getSelection())
- total += expenses;
- else
- total -= expenses;
+ amountSpinner.setSelection((int)Math.round(amount.doubleValue() * Math.pow(10, amountSpinner.getDigits())));
- totalText.setText(nf.format(total));
+ totalText.setText(nf.format(amount));
}
-
- public void setDefaultQuantity(int defaultQuantity)
- {
- this.defaultQuantity = defaultQuantity;
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 17:54:41
|
Revision: 22
http://svn.sourceforge.net/eclipsefinance/?rev=22&view=rev
Author: yukio7
Date: 2006-09-20 10:54:35 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
fix: transaction has juste one (BigDecimal)amount
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java 2006-09-20 17:53:56 UTC (rev 21)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java 2006-09-20 17:54:35 UTC (rev 22)
@@ -61,6 +61,10 @@
return this.amount;
}
+ public void setAmount(double amount) {
+ this.amount = new BigDecimal(amount);
+ }
+
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 17:54:01
|
Revision: 21
http://svn.sourceforge.net/eclipsefinance/?rev=21&view=rev
Author: yukio7
Date: 2006-09-20 10:53:56 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
new: only one static instance
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Fortune.java
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Fortune.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Fortune.java 2006-09-20 17:53:36 UTC (rev 20)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Fortune.java 2006-09-20 17:53:56 UTC (rev 21)
@@ -1,22 +1,42 @@
package net.sf.eclipsefinance.core.model;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.PlatformObject;
public class Fortune extends PlatformObject{
+ private static Fortune instance = new Fortune();
private String name = null;
private List bankList = new ArrayList();
- public Fortune(){
+ private Fortune(){
init();
}
+
+ public static Fortune getInstance(){
+ return instance;
+ }
public List getBankList() {
return this.bankList;
}
+
+ /**
+ * Loop tru te banks to find existing accounts
+ * @return list of all existing account
+ */
+ public List getAccountList() {
+ List accountList = new ArrayList();
+ Iterator bankIter = this.bankList.iterator();
+ while(bankIter.hasNext()){
+ Bank currentBank = (Bank)bankIter.next();
+ accountList.addAll(currentBank.getAccountList());
+ }
+ return accountList;
+ }
public String getName() {
return this.name;
@@ -42,7 +62,7 @@
addBank(bank1);
Account account1a = new Account("Compte courant");
bank1.addAccount(account1a);
- Account account1b = new Account("Compte \x8Epargne");
+ Account account1b = new Account("Compte epargne");
bank1.addAccount(account1b);
//Banque postale
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 17:53:43
|
Revision: 20
http://svn.sourceforge.net/eclipsefinance/?rev=20&view=rev
Author: yukio7
Date: 2006-09-20 10:53:36 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
new: link to transactions
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java 2006-09-20 17:05:25 UTC (rev 19)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Account.java 2006-09-20 17:53:36 UTC (rev 20)
@@ -1,6 +1,8 @@
package net.sf.eclipsefinance.core.model;
import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.PlatformObject;
@@ -12,6 +14,7 @@
private String IBAN = null;
private BigDecimal balance = new BigDecimal("0.0");
private Bank bank = null;
+ List transactionList = new ArrayList();
Account(String name){
this.name = name;
@@ -53,4 +56,12 @@
this.bank = bank;
}
+ public List getTransactionList() {
+ return transactionList;
+ }
+
+ public void setTransactionList(List transactionList) {
+ this.transactionList = transactionList;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 17:05:34
|
Revision: 19
http://svn.sourceforge.net/eclipsefinance/?rev=19&view=rev
Author: yukio7
Date: 2006-09-20 10:05:25 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
refactoring of core perspective
Modified Paths:
--------------
trunk/net.sf.eclipsefinance/src/net/sf/eclipsefinance/ApplicationWorkbenchAdvisor.java
Modified: trunk/net.sf.eclipsefinance/src/net/sf/eclipsefinance/ApplicationWorkbenchAdvisor.java
===================================================================
--- trunk/net.sf.eclipsefinance/src/net/sf/eclipsefinance/ApplicationWorkbenchAdvisor.java 2006-09-20 17:04:54 UTC (rev 18)
+++ trunk/net.sf.eclipsefinance/src/net/sf/eclipsefinance/ApplicationWorkbenchAdvisor.java 2006-09-20 17:05:25 UTC (rev 19)
@@ -1,6 +1,6 @@
package net.sf.eclipsefinance;
-import net.sf.eclipsefinance.core.views.CorePerspective;
+import net.sf.eclipsefinance.core.ui.views.CorePerspective;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 17:05:12
|
Revision: 18
http://svn.sourceforge.net/eclipsefinance/?rev=18&view=rev
Author: yukio7
Date: 2006-09-20 10:04:54 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
start of transaction
Modified Paths:
--------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountView.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/CoreFinanceAdapterFactory.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/CorePerspective.java
Added Paths:
-----------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/TransactionDialog.java
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java
Removed Paths:
-------------
trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/views/
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/model/Transaction.java 2006-09-20 17:04:54 UTC (rev 18)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2004-2006 Eclipse Finance.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Cottet - initial API and implementation
+ */
+
+package net.sf.eclipsefinance.core.model;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Transaction {
+
+ private Date date = null;
+ private Integer id;
+ private String memo = null;
+ private BigDecimal amount = new BigDecimal("0");
+ Map params = new HashMap();
+
+ public Transaction() {
+ }
+
+ public Transaction(Integer id) {
+ this.id =id;
+ }
+
+ public Transaction(Date date, String memo, BigDecimal amount) {
+ this.date = date;
+ this.date = date;
+ this.amount = amount;
+ }
+
+ public String getMemo() {
+ return this.memo;
+ }
+
+ public void setMemo(String memo) {
+ this.memo = memo;
+ }
+
+ public Integer getId() {
+ return this.id;
+ }
+
+ public Date getDate() {
+ return this.date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public BigDecimal getAmount() {
+ return this.amount;
+ }
+
+ public void setAmount(BigDecimal amount) {
+ this.amount = amount;
+ }
+
+ public Map getParams() {
+ return this.params;
+ }
+
+ public void setParams(Map params) {
+ this.params = params;
+ }
+
+ public void setParam(String key, String value) {
+ params.put(key, value);
+ }
+
+ public String getParam(String key) {
+ return (String)params.get(key);
+ }
+}
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/TransactionDialog.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/TransactionDialog.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/dialogs/TransactionDialog.java 2006-09-20 17:04:54 UTC (rev 18)
@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) 2004-2006 Marco Maccaferri and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ */
+
+package net.sf.eclipsefinance.core.ui.dialogs;
+
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.eclipsetrader.core.CorePlugin;
+import net.sourceforge.eclipsetrader.core.db.Account;
+import net.sourceforge.eclipsetrader.core.db.Security;
+import net.sourceforge.eclipsetrader.core.db.Transaction;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.Text;
+
+public class TransactionDialog extends TitleAreaDialog
+{
+ Account account;
+ Security security;
+ int defaultQuantity = 1;
+ Transaction transaction;
+ Text dateText;
+ Combo accountCombo;
+ Combo securityCombo;
+ Button buyButton;
+ Button sellButton;
+ Spinner quantitySpinner;
+ Spinner priceSpinner;
+ Spinner expensesSpinner;
+ Text totalText;
+ SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
+ NumberFormat nf = NumberFormat.getInstance();
+
+ public TransactionDialog(Account account, Shell parentShell)
+ {
+ super(parentShell);
+ this.account = account;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell(Shell newShell)
+ {
+ super.configureShell(newShell);
+ newShell.setText("Transaction");
+
+ nf.setGroupingUsed(true);
+ nf.setMinimumIntegerDigits(1);
+ nf.setMinimumFractionDigits(2);
+ nf.setMaximumFractionDigits(2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea(Composite parent)
+ {
+ Composite content = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout(2, false);
+ content.setLayout(gridLayout);
+ content.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+
+ Label label = new Label(content, SWT.NONE);
+ label.setText("Date / Time");
+ label.setLayoutData(new GridData(125, SWT.DEFAULT));
+ dateText = new Text(content, SWT.BORDER);
+ dateText.setLayoutData(new GridData(125, SWT.DEFAULT));
+ dateText.addFocusListener(new FocusAdapter() {
+ public void focusLost(FocusEvent e)
+ {
+ try {
+ Date date = df.parse(dateText.getText());
+ dateText.setText(df.format(date));
+ } catch(Exception e1) {
+ }
+ }
+ });
+
+ label = new Label(content, SWT.NONE);
+ label.setText("Account");
+ label.setLayoutData(new GridData(125, SWT.DEFAULT));
+ accountCombo = new Combo(content, SWT.READ_ONLY);
+ accountCombo.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+ accountCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e)
+ {
+ updateTotals();
+ }
+ });
+
+ label = new Label(content, SWT.NONE);
+ label.setText("Security");
+ label.setLayoutData(new GridData(125, SWT.DEFAULT));
+ securityCombo = new Combo(content, SWT.READ_ONLY);
+ securityCombo.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+ securityCombo.setVisibleItemCount(25);
+ securityCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e)
+ {
+ Security security = (Security)securityCombo.getData(securityCombo.getText());
+ if (security != null && security.getQuote() != null)
+ {
+ priceSpinner.setSelection((int)Math.round(security.getQuote().getLast() * Math.pow(10, priceSpinner.getDigits())));
+ updateTotals();
+ }
+ }
+ });
+
+ label = new Label(content, SWT.NONE);
+ label.setLayoutData(new GridData(125, SWT.DEFAULT));
+ Composite group = new Composite(content, SWT.NONE);
+ gridLayout = new GridLayout(2, false);
+ gridLayout.marginWidth = gridLayout.marginHeight = 0;
+ group.setLayout(gridLayout);
+ buyButton = new Button(group, SWT.RADIO);
+ buyButton.setText("Buy");
+ buyButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e)
+ {
+ updateTotals();
+ }
+ });
+ sellButton = new Button(group, SWT.RADIO);
+ sellButton.setText("Sell");
+ sellButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e)
+ {
+ updateTotals();
+ }
+ });
+
+ label = new Label(content, SWT.NONE);
+ label.setText("Quantity");
+ label.setLayoutData(new GridData(125, SWT.DEFAULT));
+ quantitySpinner = new Spinner(content, SWT.BORDER);
+ quantitySpinner.setMinimum(1);
+ quantitySpinner.setMaximum(999999);
+ quantitySpinner.setSelection(Math.abs(defaultQuantity));
+ quantitySpinner.setLayoutData(new GridData(60, SWT.DEFAULT));
+ quantitySpinner.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e)
+ {
+ updateTotals();
+ }
+ });
+
+ label = new Label(content, SWT.NONE);
+ label.setText("Price");
+ label.setLayoutData(new GridData(125, SWT.DEFAULT));
+ priceSpinner = new Spinner(content, SWT.BORDER);
+ priceSpinner.setMinimum(0);
+ priceSpinner.setMaximum(999999999);
+ priceSpinner.setDigits(4);
+ priceSpinner.setIncrement(100);
+ priceSpinner.setSelection(0);
+ priceSpinner.setLayoutData(new GridData(60, SWT.DEFAULT));
+ priceSpinner.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e)
+ {
+ updateTotals();
+ }
+ });
+
+ label = new Label(content, SWT.NONE);
+ label.setText("Expenses");
+ label.setLayoutData(new GridData(125, SWT.DEFAULT));
+ expensesSpinner = new Spinner(content, SWT.BORDER);
+ expensesSpinner.setMinimum(0);
+ expensesSpinner.setMaximum(99999999);
+ expensesSpinner.setDigits(2);
+ expensesSpinner.setIncrement(1);
+ expensesSpinner.setSelection(0);
+ expensesSpinner.setLayoutData(new GridData(60, SWT.DEFAULT));
+
+ label = new Label(content, SWT.NONE);
+ label.setText("Total");
+ label.setLayoutData(new GridData(125, SWT.DEFAULT));
+ totalText = new Text(content, SWT.BORDER|SWT.READ_ONLY|SWT.RIGHT);
+ totalText.setEnabled(false);
+ totalText.setLayoutData(new GridData(60, SWT.DEFAULT));
+
+ List list = CorePlugin.getRepository().allAccounts();
+ Collections.sort(list, new Comparator() {
+ public int compare(Object arg0, Object arg1)
+ {
+ return ((Account)arg0).getDescription().compareTo(((Account)arg1).getDescription());
+ }
+ });
+ for (Iterator iter = list.iterator(); iter.hasNext(); )
+ {
+ Account s = (Account)iter.next();
+ accountCombo.add(s.getDescription());
+ accountCombo.setData(s.getDescription(), s);
+ }
+ if (account != null)
+ accountCombo.setText(account.getDescription());
+
+ list = CorePlugin.getRepository().allSecurities();
+ Collections.sort(list, new Comparator() {
+ public int compare(Object arg0, Object arg1)
+ {
+ return ((Security)arg0).getDescription().compareTo(((Security)arg1).getDescription());
+ }
+ });
+ for (Iterator iter = list.iterator(); iter.hasNext(); )
+ {
+ Security s = (Security)iter.next();
+ securityCombo.add(s.getDescription());
+ securityCombo.setData(s.getDescription(), s);
+ }
+
+ if (transaction != null)
+ {
+ setTitle("Edit a Transaction");
+ setMessage("Enter the details of the transaction to edit");
+ dateText.setText(df.format(transaction.getDate()));
+ securityCombo.setText(transaction.getSecurity().getDescription());
+ buyButton.setSelection(transaction.getQuantity() >= 0);
+ sellButton.setSelection(transaction.getQuantity() < 0);
+ quantitySpinner.setSelection(Math.abs(transaction.getQuantity()));
+ priceSpinner.setSelection((int)Math.round(transaction.getPrice() * Math.pow(10, priceSpinner.getDigits())));
+ expensesSpinner.setSelection((int)Math.round(transaction.getExpenses() * Math.pow(10, expensesSpinner.getDigits())));
+ }
+ else
+ {
+ setTitle("Create a new Transaction");
+ setMessage("Enter the details of the transaction to create");
+ dateText.setText(df.format(Calendar.getInstance().getTime()));
+ buyButton.setSelection(defaultQuantity >= 0);
+ sellButton.setSelection(defaultQuantity < 0);
+ }
+
+ if (security != null)
+ {
+ securityCombo.setText(security.getDescription());
+ if (security.getQuote() != null)
+ priceSpinner.setSelection((int)Math.round(security.getQuote().getLast() * Math.pow(10, priceSpinner.getDigits())));
+ quantitySpinner.setFocus();
+ }
+ else
+ securityCombo.setFocus();
+
+ updateTotals();
+
+ dateText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e)
+ {
+ try {
+ df.parse(dateText.getText());
+ setErrorMessage(null);
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ } catch(Exception e1) {
+ setErrorMessage("Invalid date and time format");
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ }
+ }
+ });
+
+ return super.createDialogArea(parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#open()
+ */
+ public int open(Transaction transaction)
+ {
+ this.transaction = transaction;
+ this.security = transaction.getSecurity();
+ return super.open();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#open()
+ */
+ public int open(Security security)
+ {
+ this.security = security;
+ return super.open();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ if (transaction != null)
+ account.getTransactions().remove(transaction);
+
+ transaction = new Transaction();
+ transaction.setDate(Calendar.getInstance().getTime());
+ try {
+ transaction.setDate(df.parse(dateText.getText()));
+ } catch(Exception e) {
+ CorePlugin.logException(e);
+ }
+ transaction.setSecurity((Security)securityCombo.getData(securityCombo.getText()));
+ if (buyButton.getSelection())
+ transaction.setQuantity(quantitySpinner.getSelection());
+ else
+ transaction.setQuantity(-quantitySpinner.getSelection());
+ transaction.setPrice(priceSpinner.getSelection() / Math.pow(10, priceSpinner.getDigits()));
+ transaction.setExpenses(expensesSpinner.getSelection() / Math.pow(10, expensesSpinner.getDigits()));
+
+ account.getTransactions().add(transaction);
+ CorePlugin.getRepository().save(account);
+
+ super.okPressed();
+ }
+
+ void updateTotals()
+ {
+ int quantity = quantitySpinner.getSelection();
+ double price = priceSpinner.getSelection() / Math.pow(10, priceSpinner.getDigits());
+ double total = quantity * price;
+
+ double expenses = account.getExpenses(security, quantity, price);
+ if (transaction != null)
+ expenses = transaction.getExpenses();
+ else
+ expensesSpinner.setSelection((int)Math.round(expenses * Math.pow(10, expensesSpinner.getDigits())));
+ if (buyButton.getSelection())
+ total += expenses;
+ else
+ total -= expenses;
+
+ totalText.setText(nf.format(total));
+ }
+
+ public void setDefaultQuantity(int defaultQuantity)
+ {
+ this.defaultQuantity = defaultQuantity;
+ }
+}
Copied: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views (from rev 13, trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/views)
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountView.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/views/AccountView.java 2006-08-08 20:04:49 UTC (rev 13)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/AccountView.java 2006-09-20 17:04:54 UTC (rev 18)
@@ -1,4 +1,4 @@
-package net.sf.eclipsefinance.core.views;
+package net.sf.eclipsefinance.core.ui.views;
import net.sf.eclipsefinance.core.model.Account;
import net.sf.eclipsefinance.core.model.Bank;
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/CoreFinanceAdapterFactory.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/views/CoreFinanceAdapterFactory.java 2006-08-08 20:04:49 UTC (rev 13)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/CoreFinanceAdapterFactory.java 2006-09-20 17:04:54 UTC (rev 18)
@@ -1,4 +1,4 @@
-package net.sf.eclipsefinance.core.views;
+package net.sf.eclipsefinance.core.ui.views;
import java.util.List;
Modified: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/CorePerspective.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/views/CorePerspective.java 2006-08-08 20:04:49 UTC (rev 13)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/CorePerspective.java 2006-09-20 17:04:54 UTC (rev 18)
@@ -1,6 +1,6 @@
-package net.sf.eclipsefinance.core.views;
+package net.sf.eclipsefinance.core.ui.views;
-import net.sf.eclipsefinance.core.views.AccountView;
+import net.sf.eclipsefinance.core.ui.views.AccountView;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
Added: trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java
===================================================================
--- trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java (rev 0)
+++ trunk/net.sf.eclipsefinance.core/src/net/sf/eclipsefinance/core/ui/views/TransactionsView.java 2006-09-20 17:04:54 UTC (rev 18)
@@ -0,0 +1,415 @@
+/*
+ * Copyright (c) 2004-2006 Marco Maccaferri and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marco Maccaferri - initial API and implementation
+ */
+
+package net.sf.eclipsefinance.core.ui.views;
+
+import java.security.Security;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Comparator;
+import java.util.Observable;
+import java.util.Observer;
+
+import net.sf.eclipsefinance.core.model.Account;
+import net.sf.eclipsefinance.core.model.Transaction;
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.part.PageBookView.SelectionProvider;
+
+public class TransactionsView extends ViewPart implements ICollectionObserver
+{
+ public static final String VIEW_ID = "net.sourceforge.eclipsetrader.views.transactions";
+ private Account account;
+ private Table table;
+ private Color evenForeground = new Color(null, 0, 0, 0);
+ private Color evenBackground = new Color(null, 255, 255, 255);
+ private Color oddForeground = new Color(null, 0, 0, 0);
+ private Color oddBackground = new Color(null, 240, 240, 240);
+ private Color negativeForeground = new Color(null, 240, 0, 0);
+ private Color positiveForeground = new Color(null, 0, 192, 0);
+ private NumberFormat nf = NumberFormat.getInstance();
+ private NumberFormat pf = NumberFormat.getInstance();
+ private SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
+// private Action deleteAction = new DeleteTransactionAction(this);
+// private Action propertiesAction = new TransactionSettingsAction(this);
+ private Comparator comparator = new Comparator() {
+ public int compare(Object arg0, Object arg1)
+ {
+ return ((Transaction)arg0).getDate().compareTo(((Transaction)arg1).getDate());
+ }
+ };
+
+ public TransactionsView()
+ {
+ nf.setGroupingUsed(true);
+ nf.setMinimumIntegerDigits(1);
+ nf.setMinimumFractionDigits(2);
+ nf.setMaximumFractionDigits(2);
+
+ pf.setGroupingUsed(true);
+ pf.setMinimumIntegerDigits(1);
+ pf.setMinimumFractionDigits(4);
+ pf.setMaximumFractionDigits(4);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl(Composite parent)
+ {
+ Composite content = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.marginWidth = gridLayout.marginHeight = 0;
+ content.setLayout(gridLayout);
+
+ table = new Table(content, SWT.FULL_SELECTION|SWT.MULTI);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(false);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ table.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e)
+ {
+ updateSelection();
+ }
+ });
+ table.addMouseListener(new MouseAdapter() {
+ public void mouseDown(MouseEvent e)
+ {
+ if (table.getItem(new Point(e.x, e.y)) == null)
+ {
+ table.deselectAll();
+ updateSelection();
+ }
+ }
+ public void mouseDoubleClick(MouseEvent e)
+ {
+ TableItem[] selection = table.getSelection();
+ if (selection.length == 1)
+ {
+ Transaction transaction = (Transaction)selection[0].getData();
+ TransactionDialog dlg = new TransactionDialog(account, getViewSite().getShell());
+ dlg.open(transaction);
+ }
+ }
+ });
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setWidth(0);
+ column.setResizable(false);
+
+ column = new TableColumn(table, SWT.RIGHT);
+ column.setText("Date / Time");
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText("Code");
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText("Description");
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText("Operation");
+ column = new TableColumn(table, SWT.RIGHT);
+ column.setText("Quantity");
+ column = new TableColumn(table, SWT.RIGHT);
+ column.setText("Price");
+ column = new TableColumn(table, SWT.RIGHT);
+ column.setText("Expenses");
+ column = new TableColumn(table, SWT.RIGHT);
+ column.setText("Total");
+
+ for (int i = 1; i < table.getColumnCount(); i++)
+ table.getColumn(i).pack();
+
+ getSite().setSelectionProvider(new SelectionProvider());
+
+ // Drag and drop support
+ DropTarget target = new DropTarget(parent, DND.DROP_COPY|DND.DROP_MOVE);
+ target.setTransfer(new Transfer[] { SecurityTransfer.getInstance() });
+ target.addDropListener(new DropTargetListener() {
+ public void dragEnter(DropTargetEvent event)
+ {
+ event.detail = DND.DROP_COPY;
+ }
+
+ public void dragOver(DropTargetEvent event)
+ {
+ event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
+ }
+
+ public void dragOperationChanged(DropTargetEvent event)
+ {
+ }
+
+ public void dragLeave(DropTargetEvent event)
+ {
+ }
+
+ public void dropAccept(DropTargetEvent event)
+ {
+ }
+
+ public void drop(DropTargetEvent event)
+ {
+ event.detail = DND.DROP_COPY;
+
+ if (SecurityTransfer.getInstance().isSupportedType(event.currentDataType))
+ {
+ Security[] securities = (Security[]) event.data;
+ for (int i = 0; i < securities.length; i++)
+ {
+ TransactionDialog dlg = new TransactionDialog(account, getViewSite().getShell());
+ dlg.open(securities[i]);
+ }
+ }
+ }
+ });
+
+ MenuManager menuMgr = new MenuManager("#popupMenu", "popupMenu"); //$NON-NLS-1$ //$NON-NLS-2$
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menuManager)
+ {
+ menuManager.add(new Separator("top")); //$NON-NLS-1$
+ menuManager.add(new TransactionAction(TransactionsView.this));
+ menuManager.add(new Separator());
+ menuManager.add(deleteAction);
+ menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menuManager.add(propertiesAction);
+ menuManager.add(new Separator("bottom")); //$NON-NLS-1$
+ }
+ });
+ table.setMenu(menuMgr.createContextMenu(table));
+ getSite().registerContextMenu(menuMgr, getSite().getSelectionProvider());
+
+ account = (Account)CorePlugin.getRepository().load(Account.class, new Integer(Integer.parseInt(getViewSite().getSecondaryId())));
+ if (account != null)
+ {
+ setTitleToolTip(account.getDescription());
+ setContentDescription(account.getDescription());
+ getSite().getSelectionProvider().setSelection(new AccountSelection(account));
+
+ parent.getDisplay().asyncExec(new Runnable() {
+ public void run()
+ {
+ updateView();
+ }
+ });
+
+ account.getTransactions().addCollectionObserver(this);
+ }
+ else
+ getSite().getSelectionProvider().setSelection(new NullSelection());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ public void setFocus()
+ {
+ table.getParent().setFocus();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#dispose()
+ */
+ public void dispose()
+ {
+ if (account != null)
+ account.getTransactions().removeCollectionObserver(this);
+ super.dispose();
+ }
+
+ private void updateView()
+ {
+ table.setRedraw(false);
+
+ Object[] items = account.getTransactions().toArray();
+ for (int i = 0; i < items.length; i++)
+ {
+ TableItem tableItem = new TransactionTableItem((Transaction)items[i], table, SWT.NONE);
+ tableItem.setBackground(((i & 1) == 1) ? oddBackground : evenBackground);
+ tableItem.setForeground(((i & 1) == 1) ? oddForeground : evenForeground);
+ }
+
+ table.setRedraw(true);
+
+ for (int i = 1; i < table.getColumnCount(); i++)
+ table.getColumn(i).pack();
+ }
+
+ private void updateSelection()
+ {
+ TableItem[] selection = table.getSelection();
+ deleteAction.setEnabled(selection.length != 0);
+ propertiesAction.setEnabled(selection.length == 1);
+ }
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.eclipsetrader.core.ICollectionObserver#itemAdded(java.lang.Object)
+ */
+ public void itemAdded(final Object o)
+ {
+ table.getDisplay().asyncExec(new Runnable() {
+ public void run()
+ {
+ if (!table.isDisposed())
+ {
+ TableItem[] items = table.getItems();
+ for (int i = 0; i < items.length; i++)
+ {
+ if (comparator.compare(o, items[i].getData()) < 0)
+ {
+ new TransactionTableItem((Transaction)o, table, SWT.NONE, i);
+ for (i = 0; i < table.getItemCount(); i++)
+ {
+ table.getItem(i).setBackground(((i & 1) == 1) ? oddBackground : evenBackground);
+ table.getItem(i).setForeground(((i & 1) == 1) ? oddForeground : evenForeground);
+ }
+ for (i = 1; i < table.getColumnCount(); i++)
+ table.getColumn(i).pack();
+ return;
+ }
+ }
+ new TransactionTableItem((Transaction)o, table, SWT.NONE);
+ for (int i = 0; i < table.getItemCount(); i++)
+ {
+ table.getItem(i).setBackground(((i & 1) == 1) ? oddBackground : evenBackground);
+ table.getItem(i).setForeground(((i & 1) == 1) ? oddForeground : evenForeground);
+ }
+ for (int i = 1; i < table.getColumnCount(); i++)
+ table.getColumn(i).pack();
+ }
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see net.sourceforge.eclipsetrader.core.ICollectionObserver#itemRemoved(java.lang.Object)
+ */
+ public void itemRemoved(final Object o)
+ {
+ table.getDisplay().asyncExec(new Runnable() {
+ public void run()
+ {
+ if (!table.isDisposed())
+ {
+ TableItem[] items = table.getItems();
+ for (int i = 0; i < items.length; i++)
+ {
+ if (o.equals(items[i].getData()))
+ items[i].dispose();
+ }
+ for (int i = 0; i < table.getItemCount(); i++)
+ {
+ table.getItem(i).setBackground(((i & 1) == 1) ? oddBackground : evenBackground);
+ table.getItem(i).setForeground(((i & 1) == 1) ? oddForeground : evenForeground);
+ }
+ }
+ }
+ });
+ }
+
+ public Account getAccount()
+ {
+ return account;
+ }
+
+ public Table getTable()
+ {
+ return table;
+ }
+
+ private class TransactionTableItem extends TableItem implements Observer
+ {
+ private Transaction transaction;
+
+ public TransactionTableItem(Transaction transaction, Table parent, int style, int index)
+ {
+ super(parent, style, index);
+ init(transaction);
+ }
+
+ public TransactionTableItem(Transaction transaction, Table parent, int style)
+ {
+ super(parent, style);
+ init(transaction);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.widgets.TableItem#checkSubclass()
+ */
+ protected void checkSubclass()
+ {
+ }
+
+ private void init(Transaction transaction)
+ {
+ this.transaction = transaction;
+ setData(transaction);
+ update();
+
+ transaction.addObserver(this);
+ addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e)
+ {
+ TransactionTableItem.this.transaction.deleteObserver(TransactionTableItem.this);
+ }
+ });
+ }
+
+ private void update()
+ {
+ setText(1, df.format(transaction.getDate()));
+ setText(2, transaction.getSecurity().getCode());
+ setText(3, transaction.getSecurity().getDescription());
+ setText(4, transaction.getQuantity() >= 0 ? "Buy" : "Sell");
+ setText(5, String.valueOf(Math.abs(transaction.getQuantity())));
+ setText(6, pf.format(transaction.getPrice()));
+ setText(7, nf.format(transaction.getExpenses()));
+ setText(8, nf.format(transaction.getAmount()));
+ setForeground(8, transaction.getAmount() >= 0 ? positiveForeground : negativeForeground);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
+ */
+ public void update(Observable o, Object arg)
+ {
+ getDisplay().asyncExec(new Runnable() {
+ public void run()
+ {
+ update();
+ }
+ });
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 06:58:06
|
Revision: 17
http://svn.sourceforge.net/eclipsefinance/?rev=17&view=rev
Author: yukio7
Date: 2006-09-19 23:57:37 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
new project
Added Paths:
-----------
trunk/net.sf.eclipsefinance.converter.ubs/.classpath
trunk/net.sf.eclipsefinance.converter.ubs/.project
trunk/net.sf.eclipsefinance.converter.ubs/META-INF/
trunk/net.sf.eclipsefinance.converter.ubs/META-INF/MANIFEST.MF
trunk/net.sf.eclipsefinance.converter.ubs/build.properties
trunk/net.sf.eclipsefinance.converter.ubs/icons/
trunk/net.sf.eclipsefinance.converter.ubs/icons/sample.gif
trunk/net.sf.eclipsefinance.converter.ubs/plugin.xml
trunk/net.sf.eclipsefinance.converter.ubs/src/
trunk/net.sf.eclipsefinance.converter.ubs/src/net/
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/Activator.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/CSVEditor.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/ColorManager.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/IXMLColorConstants.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/NonRuleBasedDamagerRepairer.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/TagRule.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLConfiguration.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLDocumentProvider.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLDoubleClickStrategy.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLPartitionScanner.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLScanner.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLTagScanner.java
trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLWhitespaceDetector.java
Added: trunk/net.sf.eclipsefinance.converter.ubs/.classpath
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/.classpath (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/.classpath 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
Added: trunk/net.sf.eclipsefinance.converter.ubs/.project
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/.project (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/.project 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.sf.eclipsefinance.converter.ubs</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/net.sf.eclipsefinance.converter.ubs/META-INF/MANIFEST.MF
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/META-INF/MANIFEST.MF (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/META-INF/MANIFEST.MF 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Ubs Plug-in
+Bundle-SymbolicName: net.sf.eclipsefinance.converter.ubs; singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: net.sf.eclipsefinance.converter.ubs.Activator
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.workbench.texteditor
+Eclipse-LazyStart: true
Added: trunk/net.sf.eclipsefinance.converter.ubs/build.properties
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/build.properties (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/build.properties 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = classes/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/
Added: trunk/net.sf.eclipsefinance.converter.ubs/icons/sample.gif
===================================================================
(Binary files differ)
Property changes on: trunk/net.sf.eclipsefinance.converter.ubs/icons/sample.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/net.sf.eclipsefinance.converter.ubs/plugin.xml
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/plugin.xml (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/plugin.xml 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ name="UBS CSV Editor"
+ extensions="csv"
+ icon="icons/sample.gif"
+ contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
+ class="net.sf.eclipsefinance.converter.ubs.editors.CSV Editor"
+ id="net.sf.eclipsefinance.converter.ubs.editors.CSV Editor">
+ </editor>
+ </extension>
+
+</plugin>
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/Activator.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/Activator.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/Activator.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,61 @@
+package net.sf.eclipsefinance.converter.ubs;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "net.sf.eclipsefinance.converter.ubs";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/CSVEditor.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/CSVEditor.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/CSVEditor.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,20 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.ui.editors.text.TextEditor;
+
+public class CSVEditor extends TextEditor {
+
+ private ColorManager colorManager;
+
+ public CSVEditor() {
+ super();
+ colorManager = new ColorManager();
+ setSourceViewerConfiguration(new XMLConfiguration(colorManager));
+ setDocumentProvider(new XMLDocumentProvider());
+ }
+ public void dispose() {
+ colorManager.dispose();
+ super.dispose();
+ }
+
+}
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/ColorManager.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/ColorManager.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/ColorManager.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,28 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+public class ColorManager {
+
+ protected Map fColorTable = new HashMap(10);
+
+ public void dispose() {
+ Iterator e = fColorTable.values().iterator();
+ while (e.hasNext())
+ ((Color) e.next()).dispose();
+ }
+ public Color getColor(RGB rgb) {
+ Color color = (Color) fColorTable.get(rgb);
+ if (color == null) {
+ color = new Color(Display.getCurrent(), rgb);
+ fColorTable.put(rgb, color);
+ }
+ return color;
+ }
+}
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/IXMLColorConstants.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/IXMLColorConstants.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/IXMLColorConstants.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,11 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.swt.graphics.RGB;
+
+public interface IXMLColorConstants {
+ RGB XML_COMMENT = new RGB(128, 0, 0);
+ RGB PROC_INSTR = new RGB(128, 128, 128);
+ RGB STRING = new RGB(0, 128, 0);
+ RGB DEFAULT = new RGB(0, 0, 0);
+ RGB TAG = new RGB(0, 0, 128);
+}
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/NonRuleBasedDamagerRepairer.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/NonRuleBasedDamagerRepairer.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/NonRuleBasedDamagerRepairer.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,138 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+import org.eclipse.jface.text.presentation.IPresentationRepairer;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.swt.custom.StyleRange;
+
+public class NonRuleBasedDamagerRepairer
+ implements IPresentationDamager, IPresentationRepairer {
+
+ /** The document this object works on */
+ protected IDocument fDocument;
+ /** The default text attribute if non is returned as data by the current token */
+ protected TextAttribute fDefaultTextAttribute;
+
+ /**
+ * Constructor for NonRuleBasedDamagerRepairer.
+ */
+ public NonRuleBasedDamagerRepairer(TextAttribute defaultTextAttribute) {
+ Assert.isNotNull(defaultTextAttribute);
+
+ fDefaultTextAttribute = defaultTextAttribute;
+ }
+
+ /**
+ * @see IPresentationRepairer#setDocument(IDocument)
+ */
+ public void setDocument(IDocument document) {
+ fDocument = document;
+ }
+
+ /**
+ * Returns the end offset of the line that contains the specified offset or
+ * if the offset is inside a line delimiter, the end offset of the next line.
+ *
+ * @param offset the offset whose line end offset must be computed
+ * @return the line end offset for the given offset
+ * @exception BadLocationException if offset is invalid in the current document
+ */
+ protected int endOfLineOf(int offset) throws BadLocationException {
+
+ IRegion info = fDocument.getLineInformationOfOffset(offset);
+ if (offset <= info.getOffset() + info.getLength())
+ return info.getOffset() + info.getLength();
+
+ int line = fDocument.getLineOfOffset(offset);
+ try {
+ info = fDocument.getLineInformation(line + 1);
+ return info.getOffset() + info.getLength();
+ } catch (BadLocationException x) {
+ return fDocument.getLength();
+ }
+ }
+
+ /**
+ * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
+ */
+ public IRegion getDamageRegion(
+ ITypedRegion partition,
+ DocumentEvent event,
+ boolean documentPartitioningChanged) {
+ if (!documentPartitioningChanged) {
+ try {
+
+ IRegion info =
+ fDocument.getLineInformationOfOffset(event.getOffset());
+ int start = Math.max(partition.getOffset(), info.getOffset());
+
+ int end =
+ event.getOffset()
+ + (event.getText() == null
+ ? event.getLength()
+ : event.getText().length());
+
+ if (info.getOffset() <= end
+ && end <= info.getOffset() + info.getLength()) {
+ // optimize the case of the same line
+ end = info.getOffset() + info.getLength();
+ } else
+ end = endOfLineOf(end);
+
+ end =
+ Math.min(
+ partition.getOffset() + partition.getLength(),
+ end);
+ return new Region(start, end - start);
+
+ } catch (BadLocationException x) {
+ }
+ }
+
+ return partition;
+ }
+
+ /**
+ * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
+ */
+ public void createPresentation(
+ TextPresentation presentation,
+ ITypedRegion region) {
+ addRange(
+ presentation,
+ region.getOffset(),
+ region.getLength(),
+ fDefaultTextAttribute);
+ }
+
+ /**
+ * Adds style information to the given text presentation.
+ *
+ * @param presentation the text presentation to be extended
+ * @param offset the offset of the range to be styled
+ * @param length the length of the range to be styled
+ * @param attr the attribute describing the style of the range to be styled
+ */
+ protected void addRange(
+ TextPresentation presentation,
+ int offset,
+ int length,
+ TextAttribute attr) {
+ if (attr != null)
+ presentation.addStyleRange(
+ new StyleRange(
+ offset,
+ length,
+ attr.getForeground(),
+ attr.getBackground(),
+ attr.getStyle()));
+ }
+}
\ No newline at end of file
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/TagRule.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/TagRule.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/TagRule.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,31 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.jface.text.rules.*;
+
+public class TagRule extends MultiLineRule {
+
+ public TagRule(IToken token) {
+ super("<", ">", token);
+ }
+ protected boolean sequenceDetected(
+ ICharacterScanner scanner,
+ char[] sequence,
+ boolean eofAllowed) {
+ int c = scanner.read();
+ if (sequence[0] == '<') {
+ if (c == '?') {
+ // processing instruction - abort
+ scanner.unread();
+ return false;
+ }
+ if (c == '!') {
+ scanner.unread();
+ // comment - abort
+ return false;
+ }
+ } else if (sequence[0] == '>') {
+ scanner.unread();
+ }
+ return super.sequenceDetected(scanner, sequence, eofAllowed);
+ }
+}
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLConfiguration.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLConfiguration.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLConfiguration.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,79 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+
+public class XMLConfiguration extends SourceViewerConfiguration {
+ private XMLDoubleClickStrategy doubleClickStrategy;
+ private XMLTagScanner tagScanner;
+ private XMLScanner scanner;
+ private ColorManager colorManager;
+
+ public XMLConfiguration(ColorManager colorManager) {
+ this.colorManager = colorManager;
+ }
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+ return new String[] {
+ IDocument.DEFAULT_CONTENT_TYPE,
+ XMLPartitionScanner.XML_COMMENT,
+ XMLPartitionScanner.XML_TAG };
+ }
+ public ITextDoubleClickStrategy getDoubleClickStrategy(
+ ISourceViewer sourceViewer,
+ String contentType) {
+ if (doubleClickStrategy == null)
+ doubleClickStrategy = new XMLDoubleClickStrategy();
+ return doubleClickStrategy;
+ }
+
+ protected XMLScanner getXMLScanner() {
+ if (scanner == null) {
+ scanner = new XMLScanner(colorManager);
+ scanner.setDefaultReturnToken(
+ new Token(
+ new TextAttribute(
+ colorManager.getColor(IXMLColorConstants.DEFAULT))));
+ }
+ return scanner;
+ }
+ protected XMLTagScanner getXMLTagScanner() {
+ if (tagScanner == null) {
+ tagScanner = new XMLTagScanner(colorManager);
+ tagScanner.setDefaultReturnToken(
+ new Token(
+ new TextAttribute(
+ colorManager.getColor(IXMLColorConstants.TAG))));
+ }
+ return tagScanner;
+ }
+
+ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+ PresentationReconciler reconciler = new PresentationReconciler();
+
+ DefaultDamagerRepairer dr =
+ new DefaultDamagerRepairer(getXMLTagScanner());
+ reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
+ reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
+
+ dr = new DefaultDamagerRepairer(getXMLScanner());
+ reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+ NonRuleBasedDamagerRepairer ndr =
+ new NonRuleBasedDamagerRepairer(
+ new TextAttribute(
+ colorManager.getColor(IXMLColorConstants.XML_COMMENT)));
+ reconciler.setDamager(ndr, XMLPartitionScanner.XML_COMMENT);
+ reconciler.setRepairer(ndr, XMLPartitionScanner.XML_COMMENT);
+
+ return reconciler;
+ }
+
+}
\ No newline at end of file
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLDocumentProvider.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLDocumentProvider.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLDocumentProvider.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,25 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.ui.editors.text.FileDocumentProvider;
+
+public class XMLDocumentProvider extends FileDocumentProvider {
+
+ protected IDocument createDocument(Object element) throws CoreException {
+ IDocument document = super.createDocument(element);
+ if (document != null) {
+ IDocumentPartitioner partitioner =
+ new FastPartitioner(
+ new XMLPartitionScanner(),
+ new String[] {
+ XMLPartitionScanner.XML_TAG,
+ XMLPartitionScanner.XML_COMMENT });
+ partitioner.connect(document);
+ document.setDocumentPartitioner(partitioner);
+ }
+ return document;
+ }
+}
\ No newline at end of file
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLDoubleClickStrategy.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLDoubleClickStrategy.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLDoubleClickStrategy.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,112 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.jface.text.*;
+
+public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
+ protected ITextViewer fText;
+
+ public void doubleClicked(ITextViewer part) {
+ int pos = part.getSelectedRange().x;
+
+ if (pos < 0)
+ return;
+
+ fText = part;
+
+ if (!selectComment(pos)) {
+ selectWord(pos);
+ }
+ }
+ protected boolean selectComment(int caretPos) {
+ IDocument doc = fText.getDocument();
+ int startPos, endPos;
+
+ try {
+ int pos = caretPos;
+ char c = ' ';
+
+ while (pos >= 0) {
+ c = doc.getChar(pos);
+ if (c == '\\') {
+ pos -= 2;
+ continue;
+ }
+ if (c == Character.LINE_SEPARATOR || c == '\"')
+ break;
+ --pos;
+ }
+
+ if (c != '\"')
+ return false;
+
+ startPos = pos;
+
+ pos = caretPos;
+ int length = doc.getLength();
+ c = ' ';
+
+ while (pos < length) {
+ c = doc.getChar(pos);
+ if (c == Character.LINE_SEPARATOR || c == '\"')
+ break;
+ ++pos;
+ }
+ if (c != '\"')
+ return false;
+
+ endPos = pos;
+
+ int offset = startPos + 1;
+ int len = endPos - offset;
+ fText.setSelectedRange(offset, len);
+ return true;
+ } catch (BadLocationException x) {
+ }
+
+ return false;
+ }
+ protected boolean selectWord(int caretPos) {
+
+ IDocument doc = fText.getDocument();
+ int startPos, endPos;
+
+ try {
+
+ int pos = caretPos;
+ char c;
+
+ while (pos >= 0) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ --pos;
+ }
+
+ startPos = pos;
+
+ pos = caretPos;
+ int length = doc.getLength();
+
+ while (pos < length) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ ++pos;
+ }
+
+ endPos = pos;
+ selectRange(startPos, endPos);
+ return true;
+
+ } catch (BadLocationException x) {
+ }
+
+ return false;
+ }
+
+ private void selectRange(int startPos, int stopPos) {
+ int offset = startPos + 1;
+ int length = stopPos - offset;
+ fText.setSelectedRange(offset, length);
+ }
+}
\ No newline at end of file
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLPartitionScanner.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLPartitionScanner.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLPartitionScanner.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,21 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.jface.text.rules.*;
+
+public class XMLPartitionScanner extends RuleBasedPartitionScanner {
+ public final static String XML_COMMENT = "__xml_comment";
+ public final static String XML_TAG = "__xml_tag";
+
+ public XMLPartitionScanner() {
+
+ IToken xmlComment = new Token(XML_COMMENT);
+ IToken tag = new Token(XML_TAG);
+
+ IPredicateRule[] rules = new IPredicateRule[2];
+
+ rules[0] = new MultiLineRule("<!--", "-->", xmlComment);
+ rules[1] = new TagRule(tag);
+
+ setPredicateRules(rules);
+ }
+}
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLScanner.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLScanner.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLScanner.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,22 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.jface.text.rules.*;
+import org.eclipse.jface.text.*;
+
+public class XMLScanner extends RuleBasedScanner {
+
+ public XMLScanner(ColorManager manager) {
+ IToken procInstr =
+ new Token(
+ new TextAttribute(
+ manager.getColor(IXMLColorConstants.PROC_INSTR)));
+
+ IRule[] rules = new IRule[2];
+ //Add rule for processing instructions
+ rules[0] = new SingleLineRule("<?", "?>", procInstr);
+ // Add generic whitespace rule.
+ rules[1] = new WhitespaceRule(new XMLWhitespaceDetector());
+
+ setRules(rules);
+ }
+}
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLTagScanner.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLTagScanner.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLTagScanner.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,24 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.jface.text.*;
+import org.eclipse.jface.text.rules.*;
+
+public class XMLTagScanner extends RuleBasedScanner {
+
+ public XMLTagScanner(ColorManager manager) {
+ IToken string =
+ new Token(
+ new TextAttribute(manager.getColor(IXMLColorConstants.STRING)));
+
+ IRule[] rules = new IRule[3];
+
+ // Add rule for double quotes
+ rules[0] = new SingleLineRule("\"", "\"", string, '\\');
+ // Add a rule for single quotes
+ rules[1] = new SingleLineRule("'", "'", string, '\\');
+ // Add generic whitespace rule.
+ rules[2] = new WhitespaceRule(new XMLWhitespaceDetector());
+
+ setRules(rules);
+ }
+}
Added: trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLWhitespaceDetector.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLWhitespaceDetector.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.ubs/src/net/sf/eclipsefinance/converter/ubs/editors/XMLWhitespaceDetector.java 2006-09-20 06:57:37 UTC (rev 17)
@@ -0,0 +1,10 @@
+package net.sf.eclipsefinance.converter.ubs.editors;
+
+import org.eclipse.jface.text.rules.IWhitespaceDetector;
+
+public class XMLWhitespaceDetector implements IWhitespaceDetector {
+
+ public boolean isWhitespace(char c) {
+ return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 06:56:56
|
Revision: 16
http://svn.sourceforge.net/eclipsefinance/?rev=16&view=rev
Author: yukio7
Date: 2006-09-19 23:56:49 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
Share project 'net.sf.eclipsefinance.converter.ubs' into 'https://svn.sourceforge.net/svnroot/eclipsefinance/trunk/net.sf.eclipsefinance.converter.ubs'
Added Paths:
-----------
trunk/net.sf.eclipsefinance.converter.ubs/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-20 06:55:07
|
Revision: 15
http://svn.sourceforge.net/eclipsefinance/?rev=15&view=rev
Author: yukio7
Date: 2006-09-19 23:54:49 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
new project
Added Paths:
-----------
trunk/net.sf.eclipsefinance.converter.moneydance/.classpath
trunk/net.sf.eclipsefinance.converter.moneydance/.project
trunk/net.sf.eclipsefinance.converter.moneydance/META-INF/
trunk/net.sf.eclipsefinance.converter.moneydance/META-INF/MANIFEST.MF
trunk/net.sf.eclipsefinance.converter.moneydance/build.properties
trunk/net.sf.eclipsefinance.converter.moneydance/plugin.xml
trunk/net.sf.eclipsefinance.converter.moneydance/src/
trunk/net.sf.eclipsefinance.converter.moneydance/src/net/
trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/
trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/
trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/
trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/
trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/Activator.java
trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/popup/
trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/popup/actions/
trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/popup/actions/NewAction.java
Added: trunk/net.sf.eclipsefinance.converter.moneydance/.classpath
===================================================================
--- trunk/net.sf.eclipsefinance.converter.moneydance/.classpath (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.moneydance/.classpath 2006-09-20 06:54:49 UTC (rev 15)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
Added: trunk/net.sf.eclipsefinance.converter.moneydance/.project
===================================================================
--- trunk/net.sf.eclipsefinance.converter.moneydance/.project (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.moneydance/.project 2006-09-20 06:54:49 UTC (rev 15)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.sf.eclipsefinance.converter.moneydance</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/net.sf.eclipsefinance.converter.moneydance/META-INF/MANIFEST.MF
===================================================================
--- trunk/net.sf.eclipsefinance.converter.moneydance/META-INF/MANIFEST.MF (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.moneydance/META-INF/MANIFEST.MF 2006-09-20 06:54:49 UTC (rev 15)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Converter Csv Plug-in
+Bundle-SymbolicName: net.sf.eclipsefinance.converter.csv; singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: net.sf.eclipsefinance.converter.csv.Activator
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources
+Eclipse-LazyStart: true
Added: trunk/net.sf.eclipsefinance.converter.moneydance/build.properties
===================================================================
--- trunk/net.sf.eclipsefinance.converter.moneydance/build.properties (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.moneydance/build.properties 2006-09-20 06:54:49 UTC (rev 15)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = classes/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .
Added: trunk/net.sf.eclipsefinance.converter.moneydance/plugin.xml
===================================================================
--- trunk/net.sf.eclipsefinance.converter.moneydance/plugin.xml (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.moneydance/plugin.xml 2006-09-20 06:54:49 UTC (rev 15)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="plugin.xml"
+ id="net.sf.eclipsefinance.converter.csv.contribution1">
+ <menu
+ label="New Submenu"
+ path="additions"
+ id="net.sf.eclipsefinance.converter.csv.menu1">
+ <separator
+ name="group1">
+ </separator>
+ </menu>
+ <action
+ label="New Action"
+ class="net.sf.eclipsefinance.converter.csv.popup.actions.NewAction"
+ menubarPath="net.sf.eclipsefinance.converter.csv.menu1/group1"
+ enablesFor="1"
+ id="net.sf.eclipsefinance.converter.csv.newAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+</plugin>
Added: trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/Activator.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/Activator.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/Activator.java 2006-09-20 06:54:49 UTC (rev 15)
@@ -0,0 +1,61 @@
+package net.sf.eclipsefinance.converter.csv;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "net.sf.eclipsefinance.converter.csv";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added: trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/popup/actions/NewAction.java
===================================================================
--- trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/popup/actions/NewAction.java (rev 0)
+++ trunk/net.sf.eclipsefinance.converter.moneydance/src/net/sf/eclipsefinance/converter/csv/popup/actions/NewAction.java 2006-09-20 06:54:49 UTC (rev 15)
@@ -0,0 +1,42 @@
+package net.sf.eclipsefinance.converter.csv.popup.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class NewAction implements IObjectActionDelegate {
+
+ /**
+ * Constructor for Action1.
+ */
+ public NewAction() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ Shell shell = new Shell();
+ MessageDialog.openInformation(
+ shell,
+ "Converter Csv Plug-in",
+ "New Action was executed.");
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-09-19 17:36:20
|
Revision: 14
http://svn.sourceforge.net/eclipsefinance/?rev=14&view=rev
Author: yukio7
Date: 2006-09-19 10:36:08 -0700 (Tue, 19 Sep 2006)
Log Message:
-----------
Share project 'net.sf.eclipsefinance.converter.moneydance' into 'https://svn.sourceforge.net/svnroot/eclipsefinance/trunk/net.sf.eclipsefinance.converter.moneydance'
Added Paths:
-----------
trunk/net.sf.eclipsefinance.converter.moneydance/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <yu...@us...> - 2006-08-08 20:04:55
|
Revision: 13 Author: yukio7 Date: 2006-08-08 13:04:49 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/eclipsefinance/?rev=13&view=rev Log Message: ----------- init commit: eclipse code templates Added Paths: ----------- trunk/net.sf.eclipsefinance.settings/eclipse_3.2/ trunk/net.sf.eclipsefinance.settings/eclipse_3.2/codetemplates.xml Added: trunk/net.sf.eclipsefinance.settings/eclipse_3.2/codetemplates.xml =================================================================== --- trunk/net.sf.eclipsefinance.settings/eclipse_3.2/codetemplates.xml (rev 0) +++ trunk/net.sf.eclipsefinance.settings/eclipse_3.2/codetemplates.xml 2006-08-08 20:04:49 UTC (rev 13) @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?><templates><template autoinsert="true" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">/** + * @return the ${bare_field_name} + */</template><template autoinsert="true" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">/** + * @param ${param} the ${bare_field_name} to set + */</template><template autoinsert="true" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">/** + * ${tags} + */</template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">/* + * Copyright (c) 2006 Eclipse Finance. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Francois Cottet - initial API and implementation + */</template><template autoinsert="true" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">/** + * @author ${user} + * + * ${tags} + */</template><template autoinsert="true" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">/** + * + */</template><template autoinsert="true" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">/** + * ${tags} + */</template><template autoinsert="true" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">/* (non-Javadoc) + * ${see_to_overridden} + */</template><template autoinsert="true" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">/** + * ${tags} + * ${see_to_target} + */</template><template autoinsert="true" context="newtype_context" deleted="false" description="Newly created files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.newtype" name="newtype">${filecomment} +${package_declaration} + +${typecomment} +${type_declaration}</template><template autoinsert="true" context="classbody_context" deleted="false" description="Code in new class type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.classbody" name="classbody"> +</template><template autoinsert="true" context="interfacebody_context" deleted="false" description="Code in new interface type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name="interfacebody"> +</template><template autoinsert="true" context="enumbody_context" deleted="false" description="Code in new enum type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.enumbody" name="enumbody"> +</template><template autoinsert="true" context="annotationbody_context" deleted="false" description="Code in new annotation type bodies" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name="annotationbody"> +</template><template autoinsert="true" context="catchblock_context" deleted="false" description="Code in new catch blocks" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.catchblock" name="catchblock">// ${todo} Auto-generated catch block +${exception_var}.printStackTrace();</template><template autoinsert="true" context="methodbody_context" deleted="false" description="Code in created method stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodbody" name="methodbody">// ${todo} Auto-generated method stub +${body_statement}</template><template autoinsert="true" context="constructorbody_context" deleted="false" description="Code in created constructor stubs" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name="constructorbody">${body_statement} +// ${todo} Auto-generated constructor stub</template><template autoinsert="false" context="getterbody_context" deleted="false" description="Code in created getters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.getterbody" name="getterbody">return this.${field};</template><template autoinsert="false" context="setterbody_context" deleted="false" description="Code in created setters" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.setterbody" name="setterbody">${field} = ${param}; +</template></templates> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <yu...@us...> - 2006-08-08 19:59:32
|
Revision: 12 Author: yukio7 Date: 2006-08-08 12:59:25 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/eclipsefinance/?rev=12&view=rev Log Message: ----------- Share project 'net.sf.eclipsefinance.settings' into 'https://svn.sourceforge.net/svnroot/eclipsefinance/trunk/net.sf.eclipsefinance.settings' Added Paths: ----------- trunk/net.sf.eclipsefinance.settings/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |