Skip to content

Commit

Permalink
Bit of work on command console
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Mar 13, 2008
1 parent 0b3e6fa commit 7ad81fe
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
Expand Up @@ -131,8 +131,7 @@ public ScreenName getScreenName() {

@Override
public void setup(SymmetricDatabase c) {
// TODO Auto-generated method stub

tableModel.setup(c);
}

public void highlightLastRow(int row) {
Expand Down
Expand Up @@ -20,8 +20,13 @@
package org.jumpmind.symmetric.admin;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.jumpmind.symmetric.SymmetricEngine;
import org.jumpmind.symmetric.common.Constants;
import org.jumpmind.symmetric.model.NodeChannel;
import org.jumpmind.symmetric.service.IConfigurationService;

public class SymmetricDatabase implements Serializable {

Expand Down Expand Up @@ -62,6 +67,15 @@ public void connect() {
}
}

public List<NodeChannel> getChannels() {
if (engine != null) {
IConfigurationService configService = (IConfigurationService)engine.getApplicationContext().getBean(Constants.CONFIG_SERVICE);
return configService.getChannelsFor(true);
} else {
return new ArrayList<NodeChannel>(0);
}
}

public void disconnect() {
// TODO
}
Expand Down
Expand Up @@ -24,7 +24,9 @@

import javax.swing.table.TableCellEditor;

import org.jumpmind.symmetric.admin.SymmetricDatabase;
import org.jumpmind.symmetric.model.Channel;
import org.jumpmind.symmetric.model.NodeChannel;

public class ChannelTableModel extends ModelObjectTableModel<Channel> {

Expand Down Expand Up @@ -136,18 +138,23 @@ int getNumberOfColumns() {
return 5;
}

List<Channel> list = null;

@Override
List<Channel> getRows() {
if (list == null) {
list = new ArrayList<Channel>();
list.add(new Channel("test", 10));
}

return list;
}

@Override
public void setup(SymmetricDatabase db) {
List<NodeChannel> nc = db.getChannels();
list = new ArrayList<Channel>(nc.size());
for (NodeChannel nodeChannel : nc) {
list.add(nodeChannel);
}
}

@Override
public void save() throws ValidationException {
System.out.println("saved " + dirtyList.size() + " objects ");
Expand All @@ -164,4 +171,5 @@ Channel newRow() {
this.list.add(newChannel);
return newChannel;
}

}
Expand Up @@ -27,16 +27,21 @@
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellEditor;

import org.jumpmind.symmetric.admin.SymmetricDatabase;
import org.jumpmind.symmetric.model.Channel;

abstract public class ModelObjectTableModel<T> extends AbstractTableModel implements ListSelectionListener {

private static final long serialVersionUID = -2191025297337306895L;

int selectedRow = 0;

protected List<T> list;

public ModelObjectTableModel() {
}

abstract public void setup(SymmetricDatabase db);

public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
Expand Down
Expand Up @@ -159,7 +159,7 @@ protected List<IncomingBatchHistory> loadDataAndReturnBatches(
status = null;
}
} catch (RegistrationRequiredException ex) {
throw ex;
throw ex;
} catch (ConnectException ex) {
logger.warn(ErrorConstants.COULD_NOT_CONNECT_TO_TRANSPORT);
} catch (UnknownHostException ex) {
Expand Down

0 comments on commit 7ad81fe

Please sign in to comment.