summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
aeeab9d)
CdmStore : changed warning dialog to new method mentioned above
LanguagePreferencePage, PreferencesUtil, AbstractMenuPreferences : checks to fail nicely if not connected to a datasoruce
MessagingUtils.warningDialog(title, source, status.getMessage());
}
MessagingUtils.warningDialog(title, source, status.getMessage());
}
+ /**
+ * Standard warning dialog for the case when the application is not yet connected to the datasource
+ *
+ * @param source
+ */
+ public static void noDataSourceWarningDialog(Object source) {
+ MessagingUtils
+ .warningDialog(
+ "Application is not connected to a datastore",
+ source,
+ "The requested operation is only available when "
+ + "connected to a datasource. You may choose a datasource to connect to or create a new one in the datasource view.");
+ }
+
/**
* Displays a warning {@link org.eclipse.jface.dialogs.MessageDialog}.
*
/**
* Displays a warning {@link org.eclipse.jface.dialogs.MessageDialog}.
*
// $Id$
/**
* Copyright (C) 2007 EDIT
// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
* http://www.e-taxonomy.eu
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
private boolean isMultilanguageTextEditingCapability;
private Language globalLanguage;
private boolean isMultilanguageTextEditingCapability;
private Language globalLanguage;
private Composite createComposite(Composite parent){
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
composite.setLayout(new RowLayout(SWT.HORIZONTAL));
return composite;
}
private Composite createComposite(Composite parent){
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
composite.setLayout(new RowLayout(SWT.HORIZONTAL));
return composite;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
Composite container = new Composite(parent, SWT.NULL);
final GridLayout gridLayout = new GridLayout();
container.setLayout(gridLayout);
Composite container = new Composite(parent, SWT.NULL);
final GridLayout gridLayout = new GridLayout();
container.setLayout(gridLayout);
createSetDefaultLanguage(container);
createSetDefaultLanguage(container);
createSetMultiLanguageTextEditingCapability(container);
createSetMultiLanguageTextEditingCapability(container);
*/
private void createSetDefaultLanguage(Composite parent) {
globalLanguage = PreferencesUtil.getGlobalLanguage();
*/
private void createSetDefaultLanguage(Composite parent) {
globalLanguage = PreferencesUtil.getGlobalLanguage();
+
+ if(globalLanguage == null) {
+ return;
+ }
+
int curentSelectionIndex = 0;
int curentSelectionIndex = 0;
final Composite composite = createComposite(parent);
composite.setLayout(new RowLayout(1));
final Composite composite = createComposite(parent);
composite.setLayout(new RowLayout(1));
final Label label = new Label(composite, SWT.NONE);
label.setText("Choose the global language that will be used throughout the editor to get representations in.");
final Label label = new Label(composite, SWT.NONE);
label.setText("Choose the global language that will be used throughout the editor to get representations in.");
-
- final Combo combo_globalLanguage = new Combo(composite, SWT.NONE);
-
+
+ final Combo combo_globalLanguage = new Combo(composite, SWT.NONE);
+
List<Language> preferredLanguages = CdmStore.getTermManager().getPreferredTerms(Language.class);
List<Language> preferredLanguages = CdmStore.getTermManager().getPreferredTerms(Language.class);
for(int i = 0; i < preferredLanguages.size(); i++){
Language language = preferredLanguages.get(i);
combo_globalLanguage.add(language.getLabel(), i);
for(int i = 0; i < preferredLanguages.size(); i++){
Language language = preferredLanguages.get(i);
combo_globalLanguage.add(language.getLabel(), i);
curentSelectionIndex = i;
}
}
curentSelectionIndex = i;
}
}
combo_globalLanguage.select(curentSelectionIndex);
combo_globalLanguage.select(curentSelectionIndex);
combo_globalLanguage.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
combo_globalLanguage.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
int selectionIndex = combo_globalLanguage.getSelectionIndex();
globalLanguage = Language.getLanguageByLabel(combo_globalLanguage.getItem(selectionIndex));
}
int selectionIndex = combo_globalLanguage.getSelectionIndex();
globalLanguage = Language.getLanguageByLabel(combo_globalLanguage.getItem(selectionIndex));
}
*/
private void createSetMultiLanguageTextEditingCapability(Composite parent) {
isMultilanguageTextEditingCapability = getPreferenceStore().getBoolean(IPreferenceKeys.MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
*/
private void createSetMultiLanguageTextEditingCapability(Composite parent) {
isMultilanguageTextEditingCapability = getPreferenceStore().getBoolean(IPreferenceKeys.MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
final Composite composite = createComposite(parent);
final Composite composite = createComposite(parent);
-
- final Button button_toggle = new Button(composite, SWT.CHECK);
-
-
+
+ final Button button_toggle = new Button(composite, SWT.CHECK);
+
+
button_toggle.setText("Enable Multiple Language Editing Capability");
button_toggle.setText("Enable Multiple Language Editing Capability");
button_toggle.setSelection(isMultilanguageTextEditingCapability);
button_toggle.setSelection(isMultilanguageTextEditingCapability);
button_toggle.addSelectionListener(new SelectionAdapter(){
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
button_toggle.addSelectionListener(new SelectionAdapter(){
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
public boolean performOk() {
getPreferenceStore().setValue(IPreferenceKeys.MULTILANGUAGE_TEXT_EDITING_CAPABILITY, isMultilanguageTextEditingCapability);
PreferencesUtil.setGlobalLanguage(globalLanguage);
public boolean performOk() {
getPreferenceStore().setValue(IPreferenceKeys.MULTILANGUAGE_TEXT_EDITING_CAPABILITY, isMultilanguageTextEditingCapability);
PreferencesUtil.setGlobalLanguage(globalLanguage);
return super.performOk();
}
}
return super.performOk();
}
}
}
public static Language getGlobalLanguage() {
}
public static Language getGlobalLanguage() {
String languageUuidString = getPreferenceStore().getString(
GLOBAL_LANGUAGE_UUID);
String languageUuidString = getPreferenceStore().getString(
GLOBAL_LANGUAGE_UUID);
+ if(!CdmStore.isActive()) {
+ MessagingUtils.noDataSourceWarningDialog(languageUuidString);
+ return null;
+ }
+
if (CdmUtils.isBlank(languageUuidString)) {
return Language.getDefaultLanguage();
}
if (CdmUtils.isBlank(languageUuidString)) {
return Language.getDefaultLanguage();
}
}
public static void setGlobalLanguage(Language language) {
}
public static void setGlobalLanguage(Language language) {
- getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,
- language.getUuid().toString());
- CdmStore.setDefaultLanguage(language);
+ if(language != null) {
+ getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
+ CdmStore.setDefaultLanguage(language);
+ }
+
}
protected List<T> getTerms(){
}
protected List<T> getTerms(){
- return TermStore.getTerms(getTermClass());
+ if(!CdmStore.isActive()) {
+ return new ArrayList<T>();
+ } else {
+ return TermStore.getTerms(getTermClass());
+ }
/** {@inheritDoc} */
@Override
public void init(IWorkbench workbench) {
/** {@inheritDoc} */
@Override
public void init(IWorkbench workbench) {
- setPreferenceStore(PreferencesUtil.getPreferenceStore());
- getConversationHolder().bind();
+ setPreferenceStore(PreferencesUtil.getPreferenceStore());
+ if(!CdmStore.isActive()) {
+ MessagingUtils.noDataSourceWarningDialog(null);
+
+ } else {
+ getConversationHolder().bind();
+ }
/** {@inheritDoc} */
@Override
public boolean performOk() {
/** {@inheritDoc} */
@Override
public boolean performOk() {
+ if(!CdmStore.isActive()) {
+ return true;
+ }
+
if(checkNoneChecked()){
return false;
}
if(checkNoneChecked()){
return false;
}
return instance;
} else{// if (instance == null || !instance.isConnected) {
return instance;
} else{// if (instance == null || !instance.isConnected) {
- MessagingUtils
- .warningDialog(
- "Application is not connected to a datastore",
- instance,
- "The requested operation is only available when "
- + "connected to a datasource. You may choose a datasource to connect to or create a new one in the datasource view.");
+ MessagingUtils.noDataSourceWarningDialog(instance);
AbstractUtility.showView(CdmDataSourceViewPart.ID);
return null;
AbstractUtility.showView(CdmDataSourceViewPart.ID);
return null;