public void removeConnection() { try { Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems(); if (connections != null && !connections.isEmpty()) { for (Object obj : connections) { if (obj != null && obj instanceof UIDatabaseConnection) { UIDatabaseConnection connection = (UIDatabaseConnection) obj; DatabaseMeta databaseMeta = connection.getDatabaseMeta(); // Make sure this connection already exists and store its id for updating ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName()); if (idDatabase == null) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Delete.DoesNotExists.Message", databaseMeta.getName())); mb.setText( BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.Title")); mb.open(); } else { repository.deleteDatabaseMeta(databaseMeta.getName()); } } } } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message")); mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.Title")); mb.open(); } } catch (KettleException e) { if (mainController == null || !mainController.handleLostRepository(e)) { new ErrorDialog( shell, BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"), BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Remove.UnexpectedError.Message"), e); } } finally { refreshConnectionList(); } }
public void removePartition() { String partitionSchemaName = ""; try { Collection<UIPartition> partitions = partitionsTable.getSelectedItems(); if (partitions != null && !partitions.isEmpty()) { for (Object obj : partitions) { if (obj != null && obj instanceof UIPartition) { UIPartition partition = (UIPartition) obj; PartitionSchema partitionSchema = partition.getPartitionSchema(); partitionSchemaName = partitionSchema.getName(); // Make sure the partition to delete exists in the repository ObjectId partitionId = repository.getPartitionSchemaID(partitionSchema.getName()); if (partitionId == null) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Partition.DoesNotExists.Message", partitionSchemaName)); mb.setText( BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title")); mb.open(); } else { repository.deletePartitionSchema(partitionId); } } } } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Partition.NoItemSelected.Message")); mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title")); mb.open(); } } catch (KettleException e) { new ErrorDialog( shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title"), BaseMessages.getString( PKG, "RepositoryExplorerDialog.Partition.Delete.UnexpectedError.Message") + partitionSchemaName + "]", e); //$NON-NLS-3$ } finally { refreshPartitions(); } }
public void editConnection() { try { Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems(); if (connections != null && !connections.isEmpty()) { // Grab the first item in the list & send it to the database dialog DatabaseMeta databaseMeta = ((UIDatabaseConnection) connections.toArray()[0]).getDatabaseMeta(); // Make sure this connection already exists and store its id for updating ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName()); if (idDatabase == null) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Message")); mb.setText( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Title")); mb.open(); } else { getDatabaseDialog().setDatabaseMeta(databaseMeta); String dbName = getDatabaseDialog().open(); if (dbName != null) { dbName = dbName.trim(); if (!dbName.isEmpty()) { ObjectId idRenamed = repository.getDatabaseID(dbName); if (idRenamed == null || idRenamed.equals(idDatabase)) { // renaming to non-existing name or updating the current repository.insertLogEntry( BaseMessages.getString( PKG, "ConnectionsController.Message.UpdatingDatabase", databaseMeta.getName())); repository.save(databaseMeta, Const.VERSION_COMMENT_EDIT_VERSION, null); } else { // trying to rename to an existing name - show error dialog showAlreadyExistsMessage(); } } } // We should be able to tell the difference between a cancel and an empty database name // // else { // MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); // mb.setMessage(BaseMessages.getString(PKG, // "RepositoryExplorerDialog.Connection.Edit.MissingName.Message")); // mb.setText(BaseMessages.getString(PKG, // "RepositoryExplorerDialog.Connection.Edit.MissingName.Title")); // mb.open(); // } } } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message")); mb.setText( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Title")); mb.open(); } } catch (KettleException e) { if (mainController == null || !mainController.handleLostRepository(e)) { new ErrorDialog( shell, BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"), BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.UnexpectedError.Message"), e); } } finally { refreshConnectionList(); } }
public void editPartition() { String partitionSchemaName = ""; try { Collection<UIPartition> partitions = partitionsTable.getSelectedItems(); if (partitions != null && !partitions.isEmpty()) { // Grab the first item in the list & send it to the partition schema dialog PartitionSchema partitionSchema = ((UIPartition) partitions.toArray()[0]).getPartitionSchema(); partitionSchemaName = partitionSchema.getName(); // Make sure the partition already exists ObjectId partitionId = repository.getPartitionSchemaID(partitionSchema.getName()); if (partitionId == null) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Partition.DoesNotExists.Message", partitionSchemaName)); mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.Title")); mb.open(); } else { PartitionSchemaDialog partitionDialog = new PartitionSchemaDialog( shell, partitionSchema, repository.readDatabases(), variableSpace); if (partitionDialog.open()) { if (partitionSchema.getName() != null && !partitionSchema.getName().equals("")) { repository.insertLogEntry( BaseMessages.getString( RepositoryExplorer.class, "PartitionsController.Message.UpdatingPartition", partitionSchema.getName())); repository.save(partitionSchema, Const.VERSION_COMMENT_EDIT_VERSION, null); } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Partition.Edit.InvalidName.Message")); mb.setText( BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.Title")); mb.open(); } } } } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Partition.NoItemSelected.Message")); mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.Title")); mb.open(); } } catch (KettleException e) { new ErrorDialog( shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.Title"), BaseMessages.getString( PKG, "RepositoryExplorerDialog.Partition.Edit.UnexpectedError.Message") + partitionSchemaName + "]", e); } finally { refreshPartitions(); } }