use of org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave in project pentaho-kettle by pentaho.
the class SlavesController method refreshSlaves.
public void refreshSlaves() {
if (repository != null) {
final List<UISlave> tmpList = new ArrayList<UISlave>();
Runnable r = new Runnable() {
public void run() {
try {
ObjectId[] slaveIdList = repository.getSlaveIDs(false);
for (ObjectId slaveId : slaveIdList) {
SlaveServer slave = repository.loadSlaveServer(slaveId, null);
// Add the database slave to the list
tmpList.add(new UISlave(slave));
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
}
};
doWithBusyIndicator(r);
slaveList.setChildren(tmpList);
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave in project pentaho-kettle by pentaho.
the class SlavesController method removeSlave.
public void removeSlave() {
String slaveServerName = "";
try {
Collection<UISlave> slaves = slavesTable.getSelectedItems();
if (slaves != null && !slaves.isEmpty()) {
for (Object obj : slaves) {
if (obj != null && obj instanceof UISlave) {
UISlave slave = (UISlave) obj;
SlaveServer slaveServer = slave.getSlaveServer();
slaveServerName = slaveServer.getName();
// Make sure the slave to delete exists in the repository
ObjectId slaveId = repository.getSlaveID(slaveServer.getName());
if (slaveId == null) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.DoesNotExists.Message", slaveServerName));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Delete.Title"));
mb.open();
} else {
repository.deleteSlave(slaveId);
if (getSharedObjectSyncUtil() != null) {
getSharedObjectSyncUtil().deleteSlaveServer(slaveServer);
}
}
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.NoItemSelected.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Delete.Title"));
mb.open();
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Delete.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Delete.UnexpectedError.Message") + slaveServerName + "]", e);
}
} finally {
refreshSlaves();
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UISlave in project pentaho-kettle by pentaho.
the class SlavesController method editSlave.
public void editSlave() {
String slaveServerName = "";
try {
Collection<UISlave> slaves = slavesTable.getSelectedItems();
if (slaves != null && !slaves.isEmpty()) {
// Grab the first item in the list & send it to the slave dialog
SlaveServer slaveServer = ((UISlave) slaves.toArray()[0]).getSlaveServer();
slaveServerName = slaveServer.getName();
// Make sure the slave already exists
ObjectId slaveId = repository.getSlaveID(slaveServer.getName());
if (slaveId == null) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.DoesNotExists.Message", slaveServerName));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.Title"));
mb.open();
} else {
SlaveServerDialog ssd = new SlaveServerDialog(shell, slaveServer);
if (ssd.open()) {
if (slaveServer.getName() != null && !slaveServer.getName().equals("")) {
repository.insertLogEntry(BaseMessages.getString(PKG, "SlavesController.Message.UpdatingSlave", slaveServer.getName()));
repository.save(slaveServer, Const.VERSION_COMMENT_EDIT_VERSION, null);
if (getSharedObjectSyncUtil() != null) {
getSharedObjectSyncUtil().synchronizeSlaveServers(slaveServer, slaveServerName);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.InvalidName.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.Title"));
mb.open();
}
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.NoItemSelected.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.Title"));
mb.open();
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Slave.Edit.UnexpectedError.Message") + slaveServerName + "]", e);
}
} finally {
refreshSlaves();
}
}
Aggregations