Skip to content

Commit

Permalink
Added getAvaiableProperties() to IMoleculesEdiotrModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvid Berg authored and egonw committed Oct 2, 2009
1 parent 7d41951 commit 8458bd6
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 15 deletions.
Expand Up @@ -289,8 +289,7 @@ private SDFIndexEditorModel saveSDF(IMoleculesEditorModel model, IFile file,

IFile target = null;
Collection<Object> availableProperties = null;
if(model instanceof SDFIndexEditorModel) // FIXME save properties to sDB
availableProperties = ((SDFIndexEditorModel) model).getPropertyKeys();
availableProperties = model.getAvailableProperties();

SubMonitor loopProgress = subMonitor.newChild( 1000 );
loopProgress.setWorkRemaining( 1000*model.getNumberOfMolecules() );
Expand Down
Expand Up @@ -12,7 +12,6 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

Expand Down Expand Up @@ -57,9 +56,7 @@ public List<Object> getProperties() {
}

public Collection<Object> getAvailableProperties() {
if(model instanceof SDFIndexEditorModel)
return ((SDFIndexEditorModel)model).getPropertyKeys();
return Collections.emptySet();
return model.getAvailableProperties();
}

public void removeColumn(Object key) {
Expand Down
Expand Up @@ -10,6 +10,7 @@
******************************************************************************/
package net.bioclipse.cdk.ui.sdfeditor.editor;

import java.util.Collection;
import java.util.List;

import net.bioclipse.cdk.domain.CDKMolecule;
Expand Down Expand Up @@ -275,7 +276,10 @@ public void markDirty( int index,
public void save() {
throw new UnsupportedOperationException();
}
public Collection<Object> getAvailableProperties() {

return model.getAvailableProperties();
}
};
return editorModel;
}
Expand All @@ -289,7 +293,6 @@ public ISelection getSelection() {
if(getContentProvider() instanceof MoleculeTableContentProvider) {

int[] selected = table.getSelectionModel().getSelectedRows();
int max = getDataProvider().getRowCount();

if(selected.length==0) {
currentSelected = -1;
Expand Down
Expand Up @@ -14,6 +14,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -222,6 +223,14 @@ public void markDirty(
public void save() {
throw new UnsupportedOperationException();
}
public Collection<Object> getAvailableProperties() {

return new ArrayList<Object>(
molecules.get( 0 )
.getAtomContainer()
.getProperties()
.keySet());
}
};


Expand Down Expand Up @@ -296,6 +305,14 @@ public void markDirty( int index,

public void save() {
}
public Collection<Object> getAvailableProperties() {

return new ArrayList<Object>(
molecules.get( 0 )
.getAtomContainer()
.getProperties()
.keySet());
}
};

molTableViewer.setContentProvider(
Expand Down
Expand Up @@ -273,13 +273,12 @@ private void calculateProperties(ICDKMolecule molecule) {
Collection<IPropertyCalculator<?>> calculators = CalculatePropertyHandler
.gatherCalculators( CalculatePropertyHandler
.getConfigurationElements(), null );
if(moleculesPage.getModel() instanceof SDFIndexEditorModel) {
Collection<Object> idsx = ((SDFIndexEditorModel)moleculesPage.getModel())
.getPropertyKeys();
for(IPropertyCalculator<?> calculator:calculators) {
if( idsx.contains( calculator.getPropertyName() )) {
ids.add( calculator );
}

Collection<Object> idsx =
moleculesPage.getModel().getAvailableProperties();
for ( IPropertyCalculator<?> calculator : calculators ) {
if ( idsx.contains( calculator.getPropertyName() ) ) {
ids.add( calculator );
}
}

Expand Down
Expand Up @@ -249,7 +249,7 @@ private void readProperties(ICDKMolecule molecule) {
}
}

public Collection<Object> getPropertyKeys() {
public Collection<Object> getAvailableProperties() {
if(availableProperties==null) return Collections.emptySet();
availableProperties.addAll( propertyList.keySet() );
return new HashSet<Object>(availableProperties);
Expand Down
Expand Up @@ -12,6 +12,7 @@
package net.bioclipse.cdk.ui.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -150,4 +151,8 @@ public void save() {
throw new UnsupportedOperationException(this.getClass().getName()+
" does not support this operation yet");
}

public Collection<Object> getAvailableProperties() {
return Collections.emptySet();
}
}
Expand Up @@ -11,6 +11,7 @@
package net.bioclipse.cdk.ui.model;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -125,4 +126,8 @@ public void save() {

throw new UnsupportedOperationException("Can't save SMILES yet.");
}

public Collection<Object> getAvailableProperties() {
return Collections.emptySet();
}
}
Expand Up @@ -11,6 +11,8 @@
******************************************************************************/
package net.bioclipse.cdk.ui.views;

import java.util.Collection;

import net.bioclipse.cdk.domain.ICDKMolecule;

/**
Expand All @@ -26,4 +28,6 @@ public interface IMoleculesEditorModel {
public void markDirty(int index,ICDKMolecule moleculeToSave);

public void save();

public Collection<Object> getAvailableProperties();
}

0 comments on commit 8458bd6

Please sign in to comment.