Skip to content

Commit

Permalink
Merge pull request #363 from e-cuellar/BACKLOG-3240
Browse files Browse the repository at this point in the history
[BACKLOG-3240] Named Clusters dropdown doesn't preserve selected cluster after editing
  • Loading branch information
mdamour1976 committed May 15, 2015
2 parents 12607aa + e0620e3 commit e2e4c6b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 23 deletions.
10 changes: 8 additions & 2 deletions src/org/pentaho/di/ui/delegates/HadoopClusterDelegate.java
Expand Up @@ -70,7 +70,7 @@ public void delNamedCluster( IMetaStore metaStore, NamedCluster namedCluster ) {
spoon.setShellText();
}

public void editNamedCluster( IMetaStore metaStore, NamedCluster namedCluster, Shell shell ) {
public String editNamedCluster( IMetaStore metaStore, NamedCluster namedCluster, Shell shell ) {
if ( metaStore == null ) {
metaStore = Spoon.getInstance().getMetaStore();
}
Expand All @@ -81,10 +81,14 @@ public void editNamedCluster( IMetaStore metaStore, NamedCluster namedCluster, S
deleteNamedCluster( metaStore, namedCluster );
saveNamedCluster( metaStore, namedClusterDialog.getNamedCluster() );
spoon.refreshTree();
if ( namedClusterDialog.getNamedCluster() != null ) {
return namedClusterDialog.getNamedCluster().getName();
}
}
return null;
}

public void newNamedCluster( VariableSpace variableSpace, IMetaStore metaStore, Shell shell ) {
public String newNamedCluster( VariableSpace variableSpace, IMetaStore metaStore, Shell shell ) {
if ( metaStore == null ) {
metaStore = Spoon.getInstance().getMetaStore();
}
Expand All @@ -104,7 +108,9 @@ public void newNamedCluster( VariableSpace variableSpace, IMetaStore metaStore,

saveNamedCluster( metaStore, nc );
spoon.refreshTree();
return nc.getName();
}
return null;
}

private void deleteNamedCluster( IMetaStore metaStore, NamedCluster namedCluster ) {
Expand Down
Expand Up @@ -1501,39 +1501,52 @@ public void help() {

public void editNamedCluster() {
if ( isSelectedNamedCluster() ) {
Spoon spoon = Spoon.getInstance();
XulDialog xulDialog = (XulDialog) getXulDomContainer().getDocumentRoot().getElementById( "job-entry-dialog" );
Shell shell = (Shell) xulDialog.getRootObject();
ncDelegate.editNamedCluster( null, this.selectedNamedCluster, shell );
firePropertyChange( "namedClusters", this.selectedNamedCluster, getNamedClusters() );
String ncName = this.selectedNamedCluster != null ? this.selectedNamedCluster.getName() : null;
String newNcName = ncDelegate.editNamedCluster( null, this.selectedNamedCluster, shell );
if ( newNcName != null ) {
ncName = newNcName;
}
firePropertyChange( "namedClusters", null, getNamedClusters() );
if ( ncName != null ) {
for ( NamedCluster nc : this.namedClusters ) {
if ( nc.getName().equals( ncName ) ) {
firePropertyChange( "selectedNamedCluster", null, nc );
return;
}
}
}
}
}

public void newNamedCluster() {
Spoon spoon = Spoon.getInstance();
XulDialog xulDialog = (XulDialog) getXulDomContainer().getDocumentRoot().getElementById( "job-entry-dialog" );
Shell shell = (Shell) xulDialog.getRootObject();
ncDelegate.newNamedCluster( jobMeta, null, shell );
String ncName = this.selectedNamedCluster != null ? this.selectedNamedCluster.getName() : null;
String newNcName = ncDelegate.newNamedCluster( jobMeta, null, shell );
if ( newNcName != null ) {
ncName = newNcName;
}
firePropertyChange( "namedClusters", null, getNamedClusters() );
selectNamedCluster();
}

private void selectNamedCluster() {
@SuppressWarnings("unchecked")
XulMenuList<NamedCluster> namedClusterMenu = (XulMenuList<NamedCluster>) getXulDomContainer().getDocumentRoot().getElementById( "named-clusters" ); //$NON-NLS-1$
for ( NamedCluster nc : getNamedClusters() ) {
String cn = this.jobEntry.getClusterName();
if ( cn != null && cn.equals( nc.getName() ) ) {
namedClusterMenu.setSelectedItem( nc );
setSelectedNamedCluster( nc );
if ( ncName != null ) {
for ( NamedCluster nc : this.namedClusters ) {
if ( nc.getName().equals( ncName ) ) {
firePropertyChange( "selectedNamedCluster", null, nc );
return;
}
}
}
}
}
}

public void setSelectedNamedCluster( NamedCluster namedCluster ) {
this.selectedNamedCluster = namedCluster;
}

public NamedCluster getSelectedNamedCluster() {
return this.selectedNamedCluster;
}

public boolean isSelectedNamedCluster() {
return this.selectedNamedCluster != null;
}
Expand Down
Expand Up @@ -200,7 +200,8 @@ public NamedCluster sourceToTarget( final Integer index ) {
}

public Integer targetToSource( final NamedCluster value ) {
return null;
List<NamedCluster> clusters = controller.getNamedClusters();
return clusters.indexOf( value );
}
}).fireSourceChanged();

Expand Down

0 comments on commit e2e4c6b

Please sign in to comment.