Skip to content

Commit

Permalink
Merge pull request #806 from Mailaender/empty-molecule
Browse files Browse the repository at this point in the history
Added a help text to the molecule view
  • Loading branch information
eselmeister authored Nov 13, 2021
2 parents a66ae19 + 605e994 commit 1b0cbd9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 34 deletions.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public static String getLocation(String fileName, String size) {
String IMAGE_EXPAND_ALL = PATH_PREFIX + "expand_all.gif";
String IMAGE_COLLAPSE_ALL = PATH_PREFIX + "collapse_all.gif";
String IMAGE_SEARCH = PATH_PREFIX + "search.gif";
String IMAGE_CASE_SENSITIVE = PATH_PREFIX + "caseSensitive.gif";
String IMAGE_CASE_SENSITIVE = PATH_PREFIX + "caseSensitive.png";
String IMAGE_EVALUATE = PATH_PREFIX + "evaluate.gif";
String IMAGE_EVALUATED = PATH_PREFIX + "evaluated.gif";
String IMAGE_VALIDATE = PATH_PREFIX + "validate.gif";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_Y_ro0EAvEeqJVqzJWNzLJQ" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.peakTracesPartDescriptor" label="Peak Traces" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/peakTraces.gif" closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.PeakTracesPart"/>
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_K4RHoFfoEeqlye9AD7DqRA" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.scanBrowsePartDescriptor" label="Scan Browse" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/selectedScansDefault.gif" closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.ScanBrowsePart"/>
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_cmdKcNPYEeqN1JMWzTUFPw" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.synonymsPartDescriptor" label="Synonyms" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/tag.gif" closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.SynonymsPart"/>
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_HlylUNPeEeqN1JMWzTUFPw" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.moleculePartDescriptor" label="Molecule" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/tag.gif" tooltip="Display of molecule structures and additional informations." closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.MoleculePart"/>
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_HlylUNPeEeqN1JMWzTUFPw" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.moleculePartDescriptor" label="Molecule" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/molecule.png" tooltip="Display of molecule structures and additional informations." closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.MoleculePart"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_3PJOcAyjEeisZuYp3s9MTg" featurename="commands" parentElementId="org.eclipse.chemclipse.rcp.ide.application">
<elements xsi:type="commands:Command" xmi:id="_aoksgCWdEeu5Pepo04c08Q" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.command.partHandler" commandName="Part Handler" description="This command show/hides parts."/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ public class ExtendedMoleculeUI extends Composite implements IExtendedPartUI {

private static final Logger logger = Logger.getLogger(ExtendedMoleculeUI.class);
//
private static final String EMPTY_MESSAGE = "Please select a target to view a molecular structure.";
private static final String ERROR_MESSAGE = "The molecule image couldn't be created.";
private static final ILibraryInformation LIBRARY_INFORMATION_THIAMIN = createLibraryInformationDefault();
private static final String THIAMINE_NAME = "Thiamine";
private static final String THIAMINE_CAS = "70-16-6";
private static final String THIAMINE_SMILES = "OCCc1c(C)[n+](=cs1)Cc2cnc(C)nc(N)2";
//
private static final double SCALE_DEFAULT = 1.0d;
private static final double SCALE_DELTA = 0.1d;
Expand All @@ -81,14 +78,13 @@ public class ExtendedMoleculeUI extends Composite implements IExtendedPartUI {
private AtomicReference<InformationUI> toolbarInfo = new AtomicReference<>();
private Button buttonToolbarEdit;
private AtomicReference<Composite> toolbarEdit = new AtomicReference<>();
private TabFolder tabFolder;
private ComboViewer comboViewerServices;
private Text textInput;
private ComboViewer comboViewerInput;
private Canvas canvasMolecule;
private Text textMolecule;
//
private ILibraryInformation libraryInformation = LIBRARY_INFORMATION_THIAMIN;
private ILibraryInformation libraryInformation;
//
private double scaleFactor = SCALE_DEFAULT;
private Image imageMolecule = null;
Expand All @@ -104,7 +100,7 @@ public ExtendedMoleculeUI(Composite parent, int style) {
public void setInput(ILibraryInformation libraryInformation) {

this.libraryInformation = libraryInformation;
updateContent(getDisplay());
updateContent();
}

@Override
Expand Down Expand Up @@ -150,7 +146,7 @@ private void initialize() {
/*
* Create the image
*/
updateContent(getDisplay());
updateContent();
}

private void createToolbarMain(Composite parent) {
Expand Down Expand Up @@ -194,7 +190,6 @@ private void createToolbarEdit(Composite parent) {
private Text createTextInput(Composite parent) {

Text text = new Text(parent, SWT.BORDER);
text.setText(THIAMINE_NAME);
text.setToolTipText("Input");
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.addKeyListener(new KeyAdapter() {
Expand All @@ -204,7 +199,7 @@ public void keyReleased(KeyEvent e) {

if(isEnterPressed(e)) {
libraryInformation = createLibraryInformationByInput();
updateContent(e.display);
updateContent();
}
}
});
Expand Down Expand Up @@ -261,7 +256,7 @@ private Button createButtonCalculate(Composite parent) {
public void widgetSelected(SelectionEvent e) {

libraryInformation = createLibraryInformationByInput();
updateContent(e.display);
updateContent();
}
});
//
Expand All @@ -270,7 +265,7 @@ public void widgetSelected(SelectionEvent e) {

private void createTabFolderSection(Composite parent) {

tabFolder = new TabFolder(parent, SWT.BOTTOM);
TabFolder tabFolder = new TabFolder(parent, SWT.BOTTOM);
tabFolder.setBackgroundMode(SWT.INHERIT_DEFAULT);
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
//
Expand Down Expand Up @@ -400,8 +395,7 @@ private Button createButtonReset(Composite parent) {
public void widgetSelected(SelectionEvent e) {

scaleFactor = SCALE_DEFAULT;
libraryInformation = LIBRARY_INFORMATION_THIAMIN;
updateContent(e.display);
updateContent();
}
});
//
Expand Down Expand Up @@ -479,7 +473,7 @@ public void apply(Display display) {
private void applySettings(Display display) {

createMoleculeImage(display);
updateContent(display);
updateContent();
}

private boolean isEnterPressed(KeyEvent e) {
Expand Down Expand Up @@ -561,6 +555,21 @@ private Point adjustSize(int width, int height) {

private void drawImage(Canvas canvas, PaintEvent event) {

if(libraryInformation == null || !isSourceDataAvailable(libraryInformation)) {
/*
* Instructions
*/
Font font = getFont();
FontData[] fontData = font.getFontData();
int width = event.gc.stringExtent(EMPTY_MESSAGE).x;
int height = fontData[0].getHeight();
//
Point size = canvas.getSize();
int x = (int)(size.x / 2.0d - width / 2.0d);
int y = (int)(size.y / 2.0d - height / 2.0d);
event.gc.drawText(EMPTY_MESSAGE, x, y, true);
return;
}
createMoleculeImage(event.display);
if(imageMolecule != null) {
/*
Expand Down Expand Up @@ -664,7 +673,7 @@ private ImageServiceInput getImageInput() {
private String getExportName() {

String input = textInput.getText().trim();
String name = input.replaceAll(":", "");
String name = input.replace(":", "");
name = name.isEmpty() ? "Unkown" : name;
int length = preferenceStore.getInt(PreferenceConstants.P_LENGTH_MOLECULE_NAME_EXPORT);
if(length >= PreferenceConstants.MIN_LENGTH_NAME_EXPORT && name.length() > length) {
Expand All @@ -674,7 +683,7 @@ private String getExportName() {
}
}

private void updateContent(Display display) {
private void updateContent() {

updateWidgets();
canvasMolecule.redraw();
Expand Down Expand Up @@ -718,32 +727,21 @@ private void setTextInput() {
}
}

private static ILibraryInformation createLibraryInformationDefault() {

ILibraryInformation libraryInformation = new LibraryInformation();
//
libraryInformation.setName(THIAMINE_NAME);
libraryInformation.setCasNumber(THIAMINE_CAS);
libraryInformation.setSmiles(THIAMINE_SMILES);
//
return libraryInformation;
}

private ILibraryInformation createLibraryInformationByInput() {

ILibraryInformation libraryInformation = new LibraryInformation();
ILibraryInformation libraryInformationByInput = new LibraryInformation();
//
ImageServiceInput imageInput = getImageInput();
String text = textInput.getText().trim();
switch(imageInput) {
case SMILES:
libraryInformation.setSmiles(text);
libraryInformationByInput.setSmiles(text);
break;
default:
libraryInformation.setName(text);
libraryInformationByInput.setName(text);
break;
}
//
return libraryInformation;
return libraryInformationByInput;
}
}

0 comments on commit 1b0cbd9

Please sign in to comment.