Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Gray out context menu for DS if no models.
Also added link to discovery inside view if no models.
  • Loading branch information
olas committed Nov 1, 2012
1 parent 6e51e4e commit ad40050
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
Expand Up @@ -235,7 +235,18 @@ public void createPartControl(Composite parent) {
viewer.addSelectionChangedListener( new ISelectionChangedListener(){

public void selectionChanged( SelectionChangedEvent event ) {
updateActionStates();

updateActionStates();
Object obj = ((IStructuredSelection)event.getSelection()).getFirstElement();

//Add the case for clicking a string with link to open models UI
if (obj instanceof String) {
String str = (String)obj;
if (str.startsWith("link:Install models")){
installModelsAction.run();
}

}

JChemPaintEditor jcp=getJCPfromActiveEditor();
if (jcp==null) return;
Expand All @@ -255,7 +266,6 @@ public void run() {
});
}

Object obj = ((IStructuredSelection)event.getSelection()).getFirstElement();
if ( obj instanceof ITestResult ) {
ITestResult tr = (ITestResult) obj;

Expand Down Expand Up @@ -402,8 +412,16 @@ public void run() {
//Init viewer with available endpoints
IDSManager ds = net.bioclipse.ds.Activator.getDefault().getJavaManager();
try {
viewer.setInput(ds.getFullEndpoints().toArray());
viewer.expandAll();
if (ds.getFullEndpoints().size()>1) //There is always the uncategorized EP...
viewer.setInput(ds.getFullEndpoints().toArray());
else{
String[] msg = new String[2];
msg[0]=" No models available.";
msg[1]="link:Install models...";// from menu: 'Install > DS Models...'";
// viewer.setSorter(null);
viewer.setInput(msg);
}
viewer.expandToLevel(2);
} catch ( BioclipseException e ) {
LogUtils.handleException( e, logger, Activator.PLUGIN_ID );
viewer.setInput(new String[]{"Error initializing tests"});
Expand Down Expand Up @@ -593,10 +611,16 @@ private void fillLocalToolBar(IToolBarManager manager) {

private void updateActionStates() {

if (activeTestRuns!=null && activeTestRuns.size()>0)
if (activeTestRuns!=null && activeTestRuns.size()>0){
runAction.setEnabled( true );
else
autoRunAction.setEnabled( true );
clearAction.setEnabled( true );
}
else{
runAction.setEnabled( false );
autoRunAction.setEnabled( false );
clearAction.setEnabled( false );
}

if (isAutorun()){
autoRunAction.setImageDescriptor( Activator.getImageDecriptor( "icons/fastforward_dis2.png" ));
Expand Down Expand Up @@ -762,7 +786,7 @@ public void run() {
IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench()
.getHelpSystem();
helpSystem.displayHelpResource("/" + Activator.PLUGIN_ID +
"/html/maintopic.html");
"/html/usersguide.html");
}
};
helpAction.setText("Help");
Expand Down
Expand Up @@ -15,6 +15,7 @@
import net.bioclipse.ds.model.IDSTest;
import net.bioclipse.ds.model.ITestResult;
import net.bioclipse.ds.model.TestRun;
import net.bioclipse.ds.ui.Activator;
import net.bioclipse.ds.ui.utils.PieChartProducer;

import org.eclipse.jface.viewers.ColumnLabelProvider;
Expand Down Expand Up @@ -115,6 +116,13 @@ else if (run.getConsensusStatus()==ITestResult.INCONCLUSIVE)

// return run.getIcon();
}

else if ( element instanceof String ) {
String msg = (String) element;
if (msg.startsWith("link:"))
return Activator.getImageDecriptor( "icons/download-models.png" ).createImage();

}

return null;
}
Expand Down Expand Up @@ -142,6 +150,11 @@ else if ( element instanceof IDSTest ) {
+ dstest.getTestErrorMessage() + "]";
}
}
else if ( element instanceof String ) {
String msg = (String) element;
if (msg.startsWith("link:"))
return msg.replaceFirst("link:", "");
}

return element.toString();
}
Expand Down Expand Up @@ -187,6 +200,11 @@ else if (tr.getStatus()==TestRun.EXCLUDED){

}
}
else if ( element instanceof String ) {
String msg = (String) element;
if (msg.startsWith("link:"))
return Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
}

return Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
}
Expand Down

0 comments on commit ad40050

Please sign in to comment.