Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed broken segment width and window size settings #1173

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2021 Lablicate GmbH.
* Copyright (c) 2014, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -70,9 +70,9 @@ public String getPreferenceNode() {
@Override
public Map<String, String> getDefaultValues() {

Map<String, String> defaultValues = new HashMap<String, String>();
Map<String, String> defaultValues = new HashMap<>();
defaultValues.put(P_NOISE_CALCULATOR_ID, DEF_NOISE_CALCULATOR_ID);
defaultValues.put(DEF_SEGMENT_WIDTH, DEF_SEGMENT_WIDTH);
defaultValues.put(P_SEGMENT_WIDTH, DEF_SEGMENT_WIDTH);
return defaultValues;
}

Expand Down Expand Up @@ -102,7 +102,6 @@ public static String getSelectedNoiseCalculatorId() {
public static int getSelectedSegmentWidth() {

IEclipsePreferences preferences = INSTANCE().getPreferences();
int segmentWidth = SegmentWidth.getAdjustedSetting(preferences.get(P_SEGMENT_WIDTH, DEF_SEGMENT_WIDTH));
return segmentWidth;
return SegmentWidth.getAdjustedSetting(preferences.get(P_SEGMENT_WIDTH, DEF_SEGMENT_WIDTH));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@
Bundle-Name=Support UI
Bundle-Vendor=ChemClipse
#
demo=Demo
demo=Demo

ExtendedIntegerFieldEditor.errorMessageOddIncludingZero=Has to be an odd number including zero.
ExtendedIntegerFieldEditor.errorMessageOdd=Has to be an odd number.
ExtendedIntegerFieldEditor.errorMessageEven=Has to be an even number.

SpinnerFieldEditorOddNumber.errorMessage=Value must be odd.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@
Bundle-Name=Support UI
Bundle-Vendor=ChemClipse
#
demo=Demo
demo=Demo

ExtendedIntegerFieldEditor.errorMessageOddIncludingZero=Zahl muss ungerade sein inklusive null.
ExtendedIntegerFieldEditor.errorMessageOdd=Zahl muss ungerade sein.
ExtendedIntegerFieldEditor.errorMessageEven=Zahl muss gerade sein.

SpinnerFieldEditorOddNumber.errorMessage=Wert muss ungerade sein.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2018 Lablicate GmbH.
* Copyright (c) 2011, 2022 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -27,6 +27,12 @@ public class Activator extends AbstractActivatorUI {
* Instance
*/
private static Activator plugin;
private static BundleContext context;

public static BundleContext getContext() {

return context;
}

/*
* (non-Javadoc)
Expand All @@ -35,6 +41,7 @@ public class Activator extends AbstractActivatorUI {
public void start(BundleContext context) throws Exception {

super.start(context);
Activator.context = context;
plugin = this;
initializePreferenceStore(SupportPreferences.INSTANCE());
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2015, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.support.ui.messages;

import org.eclipse.chemclipse.support.l10n.Messages;
import org.eclipse.chemclipse.support.messages.ISupportMessages;
import org.eclipse.chemclipse.support.ui.Activator;

public class SupportMessages implements ISupportMessages {

private static Messages messages;

/**
* Returns the messages instance to get a translation.
*
* @return {@link Messages}
*/
public static Messages INSTANCE() {

if(messages == null) {
messages = new Messages(Activator.getContext().getBundle());
}
return messages;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2021 Lablicate GmbH.
* Copyright (c) 2019, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -13,6 +13,7 @@
package org.eclipse.chemclipse.support.ui.preferences.fieldeditors;

import org.eclipse.chemclipse.support.settings.IntSettingsProperty.Validation;
import org.eclipse.chemclipse.support.ui.messages.SupportMessages;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;

Expand Down Expand Up @@ -69,18 +70,18 @@ protected boolean checkState() {
return true;
}
if(number % 2 == 0) {
showErrorMessage();
showErrorMessage(SupportMessages.INSTANCE().getMessage("ExtendedIntegerFieldEditor.errorMessageOddIncludingZero"));
return false;
}
}
if(validation == Validation.ODD_NUMBER) {
if(number % 2 == 0) {
showErrorMessage();
showErrorMessage(SupportMessages.INSTANCE().getMessage("ExtendedIntegerFieldEditor.errorMessageOdd"));
return false;
}
} else if(validation == Validation.EVEN_NUMBER) {
if(number % 2 != 0) {
showErrorMessage();
showErrorMessage(SupportMessages.INSTANCE().getMessage("ExtendedIntegerFieldEditor.errorMessageEven"));
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2018 Lablicate GmbH.
* Copyright (c) 2012, 2022 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -11,16 +11,19 @@
*******************************************************************************/
package org.eclipse.chemclipse.support.ui.preferences.fieldeditors;

import org.eclipse.chemclipse.support.ui.messages.SupportMessages;
import org.eclipse.swt.widgets.Composite;

public class SpinnerFieldEditorOddNumber extends SpinnerFieldEditorBounded {

public SpinnerFieldEditorOddNumber(String name, String labelText, int min, int max, Composite parent) {

super(name, labelText, min, max, parent);
setIncrement(2);
}

public SpinnerFieldEditorOddNumber(String name, String labelText, int min, int max, int strategy, Composite parent) {

super(name, labelText, min, max, strategy, parent);
setIncrement(2);
}
Expand All @@ -30,7 +33,7 @@ protected boolean doCheckState() {

int value = getIntValue();
if(value % 2 == 0) {
setErrorMessage("Value must be odd");
setErrorMessage(SupportMessages.INSTANCE().getMessage("SpinnerFieldEditorOddNumber.errorMessage"));
return false;
}
return super.doCheckState();
Expand Down