blob: 2e7a8d1c8293275c39a49fbab70d6b5bda3413cb [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* 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:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*/
package org.eclipse.osbp.preferences.ui.page;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.osbp.preferences.Preference;
import org.eclipse.osbp.preferences.ui.component.APreferencePage;
import org.eclipse.osbp.preferences.ui.component.Item;
import org.eclipse.osbp.preferences.ui.component.Type;
import org.eclipse.swt.widgets.Composite;
public class PreferencePageMain extends APreferencePage {
public PreferencePageMain() {
super(
"main",
"Summary of the OSBP Product Configuration:"
);
//noDefaultAndApplyButton();
}
@Override
protected Item[] initializeItems() {
Item configuration;
if (isPageType(PageType.PREFENCE)) {
configuration = new Item(Type.SELECT, Preference.SELECT_PRODUCT_CONFIGURATION, "Product Configuration", store.getProjectNames());
}
else {
configuration = new Item(Type.TEXT, Preference.SHOW_PRODUCT_CONFIGURATION, "Product Configuration", false);
}
return new Item[] {
configuration,
new Item(Type.TEXT, Preference.FILE_LOCATION, "File Location", false),
new Item(Type.FILE_EDITOR, Preference.FILE_EDITOR, "Open File", true),
new Item(Type.TEXT, Preference.PRODUCT_FILE, "Product File", false),
new Item(Type.TEXT, Preference.DESKTOP_URL_PATH, "Desktop Url Path", false),
new Item(Type.TEXT, Preference.MOBILE_URL_PATH, "Mobile Url Path", false)
};
}
@Override
public void createControl(Composite parent) {
super.createControl(parent);
if (getApplyButton() != null) {
getApplyButton().setEnabled(false);
}
if (getDefaultsButton() != null) {
getDefaultsButton().setEnabled(false);
}
}
@Override
protected void performDefaults() {
super.performDefaults();
}
@Override
public boolean performOk() {
boolean retcode = super.performOk();
if (getApplyButton() != null) {
getApplyButton().setEnabled(false);
}
if (getDefaultsButton() != null) {
getDefaultsButton().setEnabled(false);
}
return retcode;
}
@Override
public void propertyChange(PropertyChangeEvent event) {
super.propertyChange(event);
if (event.getSource() instanceof FieldEditor) {
if (getEditor(Preference.SELECT_PRODUCT_CONFIGURATION) == event.getSource()) {
if (event.getNewValue() instanceof String) {
store.selectOsbpProductProject((String) event.getNewValue());
}
}
}
}
}