Skip to content

Commit

Permalink
Fixed #184 - Time Ratio Classifier - upgrade to new editor style
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Jan 5, 2022
1 parent 98d9f4c commit 8feba74
Show file tree
Hide file tree
Showing 8 changed files with 581 additions and 351 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
category="net.openchrom.xxd.classifier.supplier.ratios.ui.preferences.preferencePage"
class="net.openchrom.xxd.classifier.supplier.ratios.ui.preferences.PreferencePageTime"
id="net.openchrom.xxd.classifier.supplier.ratios.ui.preferences.preferencePageTime"
name="Time Ratio Classifier">
name="Time Ratios">
</page>
<page
category="net.openchrom.xxd.classifier.supplier.ratios.ui.preferences.preferencePage"
Expand Down Expand Up @@ -79,6 +79,13 @@
<adapter
type="org.eclipse.chemclipse.ux.extension.xxd.ui.methods.SettingsUIProvider">
</adapter>
</factory>
</factory>
<factory
adaptableType="net.openchrom.xxd.classifier.supplier.ratios.settings.TimeRatioSettings"
class="net.openchrom.xxd.classifier.supplier.ratios.ui.adapter.TimeRatioSettingsAdapterFactory">
<adapter
type="org.eclipse.chemclipse.ux.extension.xxd.ui.methods.SettingsUIProvider">
</adapter>
</factory>
</extension>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*******************************************************************************
* Copyright (c) 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:
* Philip Wenig - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.classifier.supplier.ratios.ui.adapter;

import java.io.IOException;

import org.eclipse.chemclipse.processing.supplier.ProcessorPreferences;
import org.eclipse.chemclipse.ux.extension.xxd.ui.methods.SettingsUIProvider;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.swt.widgets.Composite;

import net.openchrom.xxd.classifier.supplier.ratios.settings.TimeRatioSettings;
import net.openchrom.xxd.classifier.supplier.ratios.ui.swt.TimeRatioListEditor;

public class TimeRatioSettingsAdapterFactory implements IAdapterFactory {

@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {

if(adaptableObject instanceof TimeRatioSettings) {
TimeRatioSettings settings = (TimeRatioSettings)adaptableObject;
if(adapterType == SettingsUIProvider.class) {
return adapterType.cast(createSettingsUIProvider(settings));
}
}
return null;
}

private static SettingsUIProvider<TimeRatioSettings> createSettingsUIProvider(TimeRatioSettings adaptedSettings) {

return new SettingsUIProvider<TimeRatioSettings>() {

@Override
public SettingsUIProvider.SettingsUIControl createUI(Composite parent, ProcessorPreferences<TimeRatioSettings> preferences, boolean showProfileToolbar) throws IOException {

TimeRatioSettings userSettings = preferences.getUserSettings();
return new TimeRatioListEditor(parent, preferences, userSettings == null ? adaptedSettings : userSettings);
}
};
}

@Override
public Class<?>[] getAdapterList() {

return new Class<?>[]{SettingsUIProvider.class};
}
}
Loading

0 comments on commit 8feba74

Please sign in to comment.