List of usage examples for org.eclipse.jface.preference IPreferenceStore getString
String getString(String name);
From source file:adbconnect.Activator.java
License:Open Source License
public static String getPathToAdb() { IPreferenceStore ps = new ScopedPreferenceStore(InstanceScope.INSTANCE, "com.android.ide.eclipse.adt"); return ps.getString("com.android.ide.eclipse.adt.sdk") + File.separator + "platform-tools" + File.separator; }
From source file:ag.ion.noa4e.internal.ui.preferences.LocalOfficeApplicationPreferencesPage.java
License:Open Source License
/** * Notifies that the OK button of this page's container has been pressed. * /*from w w w . j a va2s .c o m*/ * @return false to abort the container's OK processing and true to allow * the OK to happen * * @author Joerg Sigle * @author Gerry Weirich * @author Andreas Brker * @author Markus Krger * * Adopted for Elexis by Joerg Sigle 02/2012, adding comments and monitoring output, * and reproducing the functionality of changes made by Gerry Weirich in 06/2007 * for his NOAText plugin 1.4.1 to a file obtained from an older version of the ag.ion noa library. * * Changes required because of different preference store layout in Elexis: * There are corresponding changes in: * LocalOfficeApplicationsPreferencesPage.java * PREFS_PREVENT_TERMINATION * initPreferenceValues() * performOk() * NOAUIPlugin.java * PREFERENCE_OFFICE_HOME * PREFERENCE_PREVENT_TERMINATION * internalStartApplication(). */ public boolean performOk() { System.out.println("LocalOfficeApplicationPreferencesPage: performOK() begin - Adopted to Elexis by GW/JS"); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): allocating preferenceStore = new SettingsPreferenceStore(Hub.localCfg)"); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): instead of using = NOAUIPlugin.getDefault().getPreferenceStore()"); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): Transferring settings from configuration dialog into internal storage..."); IPreferenceStore preferenceStore = new SettingsPreferenceStore(CoreHub.localCfg); preferenceStore.setValue(PREFS_PREVENT_TERMINATION, buttonPreventTermination.getSelection()); //When we read the two timeout settings, use try/catch so that data that can't be interpreted as integer numbers doesn't cause any harm. //The trim() is needed before parseInt(), otherwise an leading space will cause failure. //See corresponding code in initPreferenceValues() and performOk(). System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): ToDo: refactor to move repeatedly used constants into single places or even out of the code."); Integer timeoutBootstrapConnect = timeoutBootstrapConnectDefault; //Start by establishing a valid default setting try { timeoutBootstrapConnect = Integer.parseInt(textTimeoutBootstrapConnect.getText().trim()); //20130310js timeout made configurable for the loop found in bootstrap*.jar that would originally stop a connection attempt after 500 tries } catch (Throwable throwable) { //do not consume } if (timeoutBootstrapConnect < timeoutBootstrapConnectMin) { timeoutBootstrapConnect = timeoutBootstrapConnectMin; } ; if (timeoutBootstrapConnect > timeoutBootstrapConnectMax) { timeoutBootstrapConnect = timeoutBootstrapConnectMax; } ; preferenceStore.setValue(PREFS_TIMEOUT_BOOTSTRAP_CONNECT, timeoutBootstrapConnect.toString()); //I also write back the possibly clamped value into the dialog immediately, cause this method might have been called by Apply rather than by OK: textTimeoutBootstrapConnect.setText(timeoutBootstrapConnect.toString()); Integer timeoutThreadedWatchdog = timeoutThreadedWatchdogDefault; //Start by establishing a valid default setting try { timeoutThreadedWatchdog = Integer.parseInt(textTimeoutThreadedWatchdog.getText().trim()); //20130310js timeout made configurable for the threaded watchdog timer added in 1.4.x by js } catch (Throwable throwable) { //do not consume } if (timeoutThreadedWatchdog < timeoutThreadedWatchdogMin) { timeoutThreadedWatchdog = timeoutThreadedWatchdogMin; } ; if (timeoutThreadedWatchdog > timeoutThreadedWatchdogMax) { timeoutThreadedWatchdog = timeoutThreadedWatchdogMax; } ; preferenceStore.setValue(PREFS_TIMEOUT_THREADED_WATCHDOG, timeoutThreadedWatchdog.toString()); //I also write back the possibly clamped value into the dialog immediately, cause this method might have been called by Apply rather than by OK: textTimeoutThreadedWatchdog.setText(timeoutThreadedWatchdog.toString()); ///20130420js: noatext_jsl 1.4.9 -> 1.4.10: Adopt configurability of meaningful temporary filename from omnivore_js 1.4.4 begin for (int i = 0; i < PREFERENCE_cotf_elements.length; i++) { for (int j = 0; j < PREFERENCE_cotf_parameters.length; j++) { //Specifically, textCotfOption[0][0] and [0][2] will NOT have been created for theconstant1 element. Therefore, don't try to set anything to its content! if (textCotfOption[i][j] != null) { //Intermediate string variable: //check whether it's a valid integer. // if yes: clamp it to the range [1..nNOAText_jslPREF_cotf_element_digits_max] // If no: re-use what's already in the preferenceStore. Should that not be an integer either, then remove the content alltogether. //FIXME: Sadly, any auto produced changes are only visible when the dialog is re-opened the next time. //FIXME: The same checking and limiting mechanism could be used upon the initialization of the dialog content after it is created. String s = textCotfOption[i][j].getText().trim(); if (!PREFERENCE_cotf_elements[i].contains("constant") && (PREFERENCE_cotf_parameters[j].contains("num_digits"))) { try { Integer v1 = Integer.parseInt(s); Integer v2 = v1; if (v1 > nNOAText_jslPREF_cotf_element_digits_max) { v2 = nNOAText_jslPREF_cotf_element_digits_max; } else { if (v1 < 1) { v2 = 1; } if (v2 != v1) { s = v2.toString().trim(); } } } catch (Throwable throwable) { s = getCotfOption(i, j); try { Integer v3 = Integer.parseInt(s); } catch (Throwable throwable2) { s = ""; } } } System.out.println("LocalOfficeApplicationPreferencesPage: performOk(): About to setValue(" + PREFERENCE_BRANCH + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[j] + ", textCotfOption[" + i + "][" + j + "].toString().trim() ); which is <" + s + ">"); preferenceStore.setValue(PREFERENCE_BRANCH + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[j], s); } } } //IPreferenceStore preferenceStore = NOAUIPlugin.getDefault().getPreferenceStore(); //preferenceStore.setValue(NOAUIPlugin.PREFERENCE_PREVENT_TERMINATION, // buttonPreventTermination.getSelection()); String oldPath = preferenceStore.getString(PreferenceConstants.P_OOBASEDIR); preferenceStore.setValue(PreferenceConstants.P_OOBASEDIR, textHome.getText()); //String oldPath = preferenceStore.getString(NOAUIPlugin.PREFERENCE_OFFICE_HOME); //preferenceStore.setValue(NOAUIPlugin.PREFERENCE_OFFICE_HOME, textHome.getText()); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): Please note: There is a reference to NOAUIPlugin.getDefault()..."); System.out.println( "LocalOfficeApplicationPreferencesPage: performOk(): still left in this code; I (js) don't know whether this might be null and hence not work."); super.performOk(); if (oldPath.length() != 0 || !oldPath.equals(textHome.getText())) { if (EditorCorePlugin.getDefault().getManagedLocalOfficeApplication().isActive()) { if (MessageDialog.openQuestion(getShell(), Messages.LocalOfficeApplicationPreferencesPage_dialog_restart_workbench_title, Messages.LocalOfficeApplicationPreferencesPage_dialog_restart_workbench_message)) NOAUIPlugin.getDefault().getWorkbench().restart(); } } System.out.println("LocalOfficeApplicationPreferencesPage: performOk() return true"); return true; }
From source file:ag.ion.noa4e.internal.ui.preferences.LocalOfficeApplicationPreferencesPage.java
License:Open Source License
/** * Inits all preference values.// www . j a v a2s .c o m * * @author Joerg Sigle * @author Gerry Weirich * @author Andreas Brker * @author Markus Krger * * Adopted for Elexis by Joerg Sigle 02/2012, adding comments and monitoring output, * and reproducing the functionality of changes made by Gerry Weirich in 06/2007 * for his NOAText plugin 1.4.1 to a file obtained from an older version of the ag.ion noa library. * * Changes required because of different preference store layout in Elexis. * There are corresponding changes in: * LocalOfficeApplicationsPreferencesPage.java * PREFS_PREVENT_TERMINATION * initPreferenceValues() * performOk() * NOAUIPlugin.java * PREFERENCE_OFFICE_HOME * PREFERENCE_PREVENT_TERMINATION * internalStartApplication(). */ private void initPreferenceValues() { System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues() begin - adopted for Elexis and NOAText_jsl by GW/JS"); System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): allocating preferenceStore = new SettingsPreferenceStore(Hub.localCfg)"); System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): instead of using = NOAUIPlugin.getDefault().getPreferenceStore()"); System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): initializing dialog fields from internal storage or default values"); IPreferenceStore preferenceStore = new SettingsPreferenceStore(CoreHub.localCfg); String officeHomePath = preferenceStore.getString(PreferenceConstants.P_OOBASEDIR); boolean preventTermination = preferenceStore.getBoolean(PREFS_PREVENT_TERMINATION); //IPreferenceStore preferenceStore = NOAUIPlugin.getDefault().getPreferenceStore(); //String officeHomePath = preferenceStore.getString(NOAUIPlugin.PREFERENCE_OFFICE_HOME); //boolean preventTermination = preferenceStore.getBoolean(NOAUIPlugin.PREFERENCE_PREVENT_TERMINATION); textHome.setText(officeHomePath); buttonPreventTermination.setSelection(preventTermination); //When we read the two timeout settings, use try/catch so that data that can't be interpreted as integer numbers doesn't cause any harm. //The trim() is needed before parseInt(), otherwise an leading space will cause failure (though that is less probable in a string coming from internal storage). //See corresponding code in initPreferenceValues() and performOk(). System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): ToDo: refactor to move repeatedly used constants into single places or even out of the code."); Integer timeoutBootstrapConnect = getTimeoutBootstrapConnect(preferenceStore); //This also observes defaults and min/max values textTimeoutBootstrapConnect.setText(timeoutBootstrapConnect.toString()); Integer timeoutThreadedWatchdog = getTimeoutThreadedWatchdog(preferenceStore); //This also observes defaults and min/max values textTimeoutThreadedWatchdog.setText(timeoutThreadedWatchdog.toString()); //20130420js: noatext_jsl 1.4.9 -> 1.4.10: Adopt configurability of meaningful temporary filename from omnivore_js 1.4.4 begin for (int i = 0; i < PREFERENCE_cotf_elements.length; i++) { for (int j = 0; j < PREFERENCE_cotf_parameters.length; j++) { //Intermediate string variable just to supply debugging output. String s = getCotfOption(preferenceStore, i, j); //Specifically, textCotfOption[0][0] and [0][2] will NOT have been created for theconstant1 element. Therefore, don't try to set them to anything! if (textCotfOption[i][j] != null) { System.out.println( "LocalOfficeApplicationPreferencesPage: initPreferenceValues(): About to set textCotfOption[" + i + "][" + j + "] to <" + s + ">..."); textCotfOption[i][j].setText(s); } } } System.out.println("LocalOfficeApplicationPreferencesPage: initPreferenceValues() end"); }
From source file:ag.ion.noa4e.internal.ui.preferences.LocalOfficeApplicationPreferencesPage.java
License:Open Source License
public static Integer getTimeoutBootstrapConnect(IPreferenceStore preferenceStore) { System.out.println("LocalOfficeApplicationPreferencesPage: getTimeoutBootstrapConnect begin"); Integer timeoutBootstrapConnect = timeoutBootstrapConnectDefault; //Start by establishing a valid default setting try {/*from ww w .ja v a2s . c o m*/ timeoutBootstrapConnect = Integer .parseInt(preferenceStore.getString(PREFS_TIMEOUT_BOOTSTRAP_CONNECT).trim()); //20130310js timeout made configurable for the loop found in bootstrap*.jar that would originally stop a connection attempt after 500 tries } catch (Throwable throwable) { //do not consume } if (timeoutBootstrapConnect < timeoutBootstrapConnectMin) { timeoutBootstrapConnect = timeoutBootstrapConnectMin; } ; if (timeoutBootstrapConnect > timeoutBootstrapConnectMax) { timeoutBootstrapConnect = timeoutBootstrapConnectMax; } ; System.out.println("LocalOfficeApplicationPreferencesPage: getTimeoutBootstrapConnect returning " + timeoutBootstrapConnect); return timeoutBootstrapConnect; }
From source file:ag.ion.noa4e.internal.ui.preferences.LocalOfficeApplicationPreferencesPage.java
License:Open Source License
public static Integer getTimeoutThreadedWatchdog(IPreferenceStore preferenceStore) { System.out.println("LocalOfficeApplicationPreferencesPage: getTimeoutThreadedWatchdog begin"); Integer timeoutThreadedWatchdog = timeoutThreadedWatchdogDefault; //Start by establishing a valid default setting try {//from w w w .j a va2 s . co m timeoutThreadedWatchdog = Integer .parseInt(preferenceStore.getString(PREFS_TIMEOUT_THREADED_WATCHDOG).trim()); //20130310js timeout made configurable for the threaded watchdog timer added in 1.4.x by js } catch (Throwable throwable) { //do not consume } if (timeoutThreadedWatchdog < timeoutThreadedWatchdogMin) { timeoutThreadedWatchdog = timeoutThreadedWatchdogMin; } ; if (timeoutThreadedWatchdog > timeoutThreadedWatchdogMax) { timeoutThreadedWatchdog = timeoutThreadedWatchdogMax; } ; System.out.println("LocalOfficeApplicationPreferencesPage: getTimeoutThreadedWatchdog returning " + timeoutThreadedWatchdog); return timeoutThreadedWatchdog; }
From source file:ag.ion.noa4e.internal.ui.preferences.LocalOfficeApplicationPreferencesPage.java
License:Open Source License
public static String getCotfOption(IPreferenceStore preferenceStore, int i, int j) { System.out.println("LocalOfficeApplicationPreferencesPage: getCotfOption begin"); //Start by establishing a valid default setting. //We do NOT need to hard code anything like the pre noatext_jsl 1.4.9 used noa_1234567890123456.odt here, //because we can better recognize and handle a fully unconfigured setup further down where we actually create the temp file. String getCotfOption;//w w w. j a v a 2 s. c om getCotfOption = ""; try { getCotfOption = preferenceStore.getString(PREFERENCE_BRANCH + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[j]).trim(); } catch (Throwable throwable) { //do not consume } System.out.println("LocalOfficeApplicationPreferencesPage: getCotfOption returning " + getCotfOption); return getCotfOption; }
From source file:ag.ion.noa4e.internal.ui.preferences.LocalOfficeApplicationPreferencesPage.java
License:Open Source License
public static String getNOAText_jslTemp_Filename_Element(IPreferenceStore preferenceStore, String element_key, String element_data) {//from w w w. j a va2 s .c o m System.out .println("LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: element_key=<" + element_key + ">"); StringBuffer element_data_processed = new StringBuffer(); Integer nCotfRules = PREFERENCE_cotf_elements.length; for (int i = 0; i < nCotfRules; i++) { System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: PREFERENCE_cotf_elements[" + i + "]=<" + PREFERENCE_cotf_elements[i] + ">"); if (PREFERENCE_cotf_elements[i].equals(element_key)) { System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: Match!"); if (element_key.contains("constant")) { //Since omnivore_js 1.4.5 / noatext_jsl 1.4.12: //Mask all characters that shall not appear in the generated filename from add_trail_char. //The masking is implemented here, and not merely after the input dialog, so that unwanted characters are caught //even if they were introduced through manipulated configuration files or outdated settings. //Do NOT trim leadig and trailing space however - some user might want a single space as separation character. String constant = cleanStringFromUnwantedCharsAndTrim( preferenceStore.getString(PREFERENCE_BRANCH + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[1]), cotf_unwanted_chars); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: returning constant=<" + constant + ">"); return constant; } else { //Shall we return ANY digits at all for this element, and later on: shall we cut down or extend the processed string to some defined number of digits? String snum_digits = preferenceStore.getString(PREFERENCE_BRANCH + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[1]).trim(); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: snum_digits=<" + snum_digits + ">"); //If the num_digits for this element is empty, then return an empty result - the element is disabled. if (snum_digits.isEmpty()) { return ""; } Integer num_digits = -1; if (snum_digits != null) { try { num_digits = Integer.parseInt(snum_digits); } catch (Throwable throwable) { //do not consume } } //if num_digits for this element is <= 0, then return an empty result - the element is disabled. if (num_digits <= 0) { return ""; } if (num_digits > nNOAText_jslPREF_cotf_element_digits_max) { num_digits = nNOAText_jslPREF_cotf_element_digits_max; } System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: num_digits=<" + num_digits + ">"); //Start with the passed element_data string String element_data_incoming = element_data.trim(); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: element_data_incoming=<" + element_data_incoming + ">"); //Remove all characters that shall not appear in the generated filename and trim leading and trailing whitespace String element_data_processed5 = cleanStringFromUnwantedCharsAndTrim(element_data_incoming, cotf_unwanted_chars).trim(); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: element_data_processed5=<" + element_data_processed5 + ">"); //filter out some special unwanted strings from the title that may have entered while importing and partially renaming files String element_data_processed4 = element_data_processed5 .replaceAll("_noa[0-9]+\056[a-zA-Z0-9]{0,3}", ""); //remove filename remainders like _noa635253160443574060.doc String element_data_processed3 = element_data_processed4 .replaceAll("noa[0-9]+\056[a-zA-Z0-9]{0,3}", ""); //remove filename remainders like noa635253160443574060.doc String element_data_processed2 = element_data_processed3 .replaceAll("_omni_[0-9]+_vore\056[a-zA-Z0-9]{0,3}", ""); //remove filename remainders like _omni_635253160443574060_vore.pdf String element_data_processed1 = element_data_processed2 .replaceAll("omni_[0-9]+_vore\056[a-zA-Z0-9]{0,3}", ""); //remove filename remainders like omni_635253160443574060_vore.pdf System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: element_data_processed1=<" + element_data_processed1 + ">"); //Limit the length of the result if it exceeds the specified or predefined max number of digits if (element_data_processed1.length() > num_digits) { element_data_processed1 = element_data_processed1.substring(0, num_digits); } System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: num_digits=<" + num_digits + ">"); //If a leading fill character is given, and the length of the result is below the specified max_number of digits, then fill it up. //Note: We could also check whether the num_digits has been given. Instead, I use the default max num of digits if not. //Since omnivore_js 1.4.5 / noatext_jsl 1.4.12: //Mask all characters that shall not appear in the generated filename from add_trail_char. //The masking is implemented here, and not merely after the input dialog, so that unwanted characters are caught //even if they were introduced through manipulated configuration files or outdated settings. //Do NOT trim leadig and trailing space however - some user might want a single space as separation character. String lead_fill_char = cleanStringFromUnwantedCharsAndTrim( preferenceStore.getString(PREFERENCE_BRANCH + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[0]), cotf_unwanted_chars); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: lead_fill_char=<" + lead_fill_char + ">"); if ((lead_fill_char != null) && (lead_fill_char.length() > 0) && (element_data_processed1.length() < num_digits)) { lead_fill_char = lead_fill_char.substring(0, 1); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: lead_fill_char=<" + lead_fill_char + ">"); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: num_digits=<" + num_digits + ">"); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: element_data_processed1.length()=<" + element_data_processed1.length() + ">"); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: element_data_processed1=<" + element_data_processed1 + ">"); for (int n = element_data_processed1.length(); n <= num_digits; n++) { element_data_processed.append(lead_fill_char); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: n, element_data_processed=" + n + ", <" + element_data_processed + ">"); } } element_data_processed.append(element_data_processed1); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: element_data_processed=<" + element_data_processed + ">"); //If an add trailing character is given, add one (typically, this would be a space or an underscore). //Even if a string is entered in the configuration dialog, only the first valid character is used. //Since omnivore_js 1.4.5 / noatext_jsl 1.4.12: //Mask all characters that shall not appear in the generated filename from add_trail_char. //The masking is implemented here, and not merely after the input dialog, so that unwanted characters are caught //even if they were introduced through manipulated configuration files or outdated settings. //Do NOT trim leadig and trailing space however - some user might want a single space as separation character. String add_trail_char = cleanStringFromUnwantedCharsAndTrim( preferenceStore.getString(PREFERENCE_BRANCH + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[2]), cotf_unwanted_chars); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: add_trail_char=<" + add_trail_char + ">"); if ((add_trail_char != null) && (add_trail_char.length() > 0)) { add_trail_char = add_trail_char.substring(0, 1); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: add_trail_char=<" + add_trail_char + ">"); element_data_processed.append(add_trail_char); System.out.println( "LocalOfficeApplicationPreferencePage: getNOAText_jslTemp_Filename_Element: element_data_processed=<" + element_data_processed + ">"); } } return element_data_processed.toString(); //This also breaks the for loop } // if ... equals(element_key) } //for int i... return ""; //default return value, if nothing is defined. }
From source file:ag.ion.noa4e.ui.NOAUIPlugin.java
License:Open Source License
/** * Starts local office application./*from w w w . j a v a 2 s .c om*/ * * @param shell shell to be used * @param officeApplication office application to be started * * @return information whether the office application was started or not - only * if the status severity is <code>IStatus.OK</code> the application was started * * @author Joerg Sigle * @date 24.06.2012 * @date 20.02.2012 * * @author Andreas Brker * @date 28.06.2006 */ public static IStatus startLocalOfficeApplication(Shell shell, IOfficeApplication officeApplication) { System.out.println("NOAUIPlugin: startLocalOfficeApplication(Shell, officeApplication) begin"); while (true) { System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): while (true) trying to start..."); IStatus status = internalStartApplication(shell, officeApplication); System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): returned from trying to start."); if (status == null) System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): status==null"); else System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): status=" + status.toString()); if (status.getSeverity() == IStatus.ERROR) { System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): WARNING: status.getSeverity()==IStatus.ERROR"); if (MessageDialog.openQuestion(shell, Messages.NOAUIPlugin_dialog_change_preferences_title, Messages.NOAUIPlugin_dialog_change_preferences_message)) { PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell, LocalOfficeApplicationPreferencesPage.PAGE_ID, null, null); if (preferenceDialog.open() == Window.CANCEL) return Status.CANCEL_STATUS; else continue; } } else System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): SUCCESS: !status.getSeverity()==IStatus.ERROR"); try { //My warning in the following line referred to the original noa4e code: //System.out.println("NOAUIPlugin: internalStartApplication(2): getting officeHome (WARNING: probably from the wrong source)..."); System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): getting officeHome..."); System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): Using js mod adopted for Elexis, reproducing prior GW adoptions, P_OOBASEDIR via ...(Hub.localCfg)"); //JS modified this: //The original code tries to access a preference store which is not used in Elexis, //according to GWs mods in (back then:) LocalOfficeApplicationPreferencesPage.java //Unsuitable original line, removed: //String officeHome = getDefault().getPreferenceStore().getString(PREFERENCE_OFFICE_HOME); //Newly inserted lines: IPreferenceStore preferenceStore = new SettingsPreferenceStore(CoreHub.localCfg); String officeHome = preferenceStore.getString(PreferenceConstants.P_OOBASEDIR); if (officeHome == null) System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): WARNING: officeHome==null"); else System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): officeHome=" + officeHome); System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): trying to get preventTermination setting..."); //My warning in the following line referred to the original noa4e code: //System.out.println("NOAUIPlugin: WARNING: THIS PROBABLY REFERENCES THE WRONG PREFERENCE STORE. SEE LocalPreferences...GWeirich/JS mods"); //JS modified this: //The original code tries to access a preference store which is not used in Elexis, //according to GWs mods in (back then:) LocalOfficeApplicationPreferencesPage.java //Unsuitable original line, removed: //boolean preventTermination = getDefault().getPreferenceStore().getBoolean(PREFERENCE_PREVENT_TERMINATION); //Newly inserted lines: //Already declared further above: IPreferenceStore preferenceStore = new SettingsPreferenceStore(Hub.localCfg); boolean preventTermination = preferenceStore.getBoolean(PREFS_PREVENT_TERMINATION); System.out.println("NOAUIPlugin: startLocalOfficeApplication(2): got preventTermination setting=" + preventTermination); if (preventTermination) { System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): trying officeApplication.getDesktopService().activateTerminationPrevention()..."); officeApplication.getDesktopService().activateTerminationPrevention(); System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): SUCCESS: officeApplication.getDesktopService().activateTerminationPrevention()"); } } catch (OfficeApplicationException officeApplicationException) { //no prevention System.out.println( "NOAUIPlugin: startLocalOfficeApplication(2): FAILED: preventTermination could NOT be set."); } System.out.println("NOAUIPlugin: startLocalOfficeApplication(2) end, returning status"); return status; } }
From source file:ag.ion.noa4e.ui.NOAUIPlugin.java
License:Open Source License
/** * Internal method in order to start the office application. * //from ww w . j av a 2 s. c o m * @param shell shell to be used * @param officeApplication office application to be used * * @return status information * * @author Joerg Sigle * @date 24.06.2012 * @date 20.02.2012 00:57 * * @author Andreas Brker * @date 28.06.2006 * * Adopted for Elexis by Joerg Sigle 02/2012, adding the following line. * Changes required because of different preference store layout in Elexis. * There are corresponding changes in: * LocalOfficeApplicationsPreferencesPage.java * PREFS_PREVENT_TERMINATION * initPreferenceValues() * performOk() * NOAUIPlugin.java * PREFERENCE_OFFICE_HOME * PREFERENCE_PREVENT_TERMINATION * internalStartApplication(). */ private static IStatus internalStartApplication(final Shell shell, IOfficeApplication officeApplication) { System.out.println("NOAUIPlugin: internalStartApplication() begin"); if (officeApplication.isActive()) { System.out.println( "NOAUIPlugin: internalStartApplication(): officeApplication.isActive(), so returning immediately."); return Status.OK_STATUS; } System.out.println( "NOAUIPlugin: internalStartApplication(): !officeApplication.isActive(), so starting it up..."); boolean configurationChanged = false; boolean canStart = false; String home = null; HashMap configuration = new HashMap(1); //My warning in the following line referred to the original noa4e code: //System.out.println("NOAUIPlugin: internalStartApplication(): getting officeHome (WARNING: probably from the wrong source)..."); System.out.println("NOAUIPlugin: internalStartApplication(): getting officeHome..."); System.out.println( "NOAUIPlugin: internalStartApplication(): Using js mod adopted for Elexis, reproducing prior GW adoptions, P_OOBASEDIR via ...(Hub.localCfg)"); //JS modified this: //The original code tries to access a preference store which is not used in Elexis, //according to GWs mods in (back then:) LocalOfficeApplicationPreferencesPage.java //Unsuitable original line, removed: //String officeHome = getDefault().getPreferenceStore().getString(PREFERENCE_OFFICE_HOME); //Newly inserted lines: IPreferenceStore preferenceStore = new SettingsPreferenceStore(CoreHub.localCfg); String officeHome = preferenceStore.getString(PreferenceConstants.P_OOBASEDIR); if (officeHome == null) System.out.println("NOAUIPlugin: internalStartApplication(): WARNING: officeHome==null"); else System.out.println("NOAUIPlugin: internalStartApplication(): officeHome=" + officeHome); if (officeHome.length() != 0) { File file = new File(officeHome); if (file.canRead()) { System.out.println( "NOAUIPlugin: internalStartApplication(): Check: officeHome is a valid path. Setting canStart to true."); configuration.put(IOfficeApplication.APPLICATION_HOME_KEY, officeHome); canStart = true; } else { System.out.println( "NOAUIPlugin: internalStartApplication(): WARNING: officeHome is NOT a valid path. Leaving canStart at false."); MessageDialog.openWarning(shell, Messages.NOAUIPlugin_dialog_warning_invalid_path_title, Messages.NOAUIPlugin_dialog_warning_invalid_path_message); } } System.out.println("NOAUIPlugin: internalStartApplication(): canStart=" + canStart); if (!canStart) { System.out.println( "NOAUIPlugin: internalStartApplication(): canStart==false; trying to auto locate available office suite installations..."); configurationChanged = true; ILazyApplicationInfo[] applicationInfos = null; boolean configurationCompleted = false; try { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); FindApplicationInfosOperation findApplicationInfosOperation = new FindApplicationInfosOperation(); progressMonitorDialog.run(true, true, findApplicationInfosOperation); applicationInfos = findApplicationInfosOperation.getApplicationsInfos(); if (applicationInfos.length == 1) { if (applicationInfos[0].getMajorVersion() == 2 || (applicationInfos[0].getMajorVersion() == 1 && applicationInfos[0].getMinorVersion() == 9)) { configuration.put(IOfficeApplication.APPLICATION_HOME_KEY, applicationInfos[0].getHome()); configurationCompleted = true; } } } catch (Throwable throwable) { System.out.println( "NOAUIPlugin: internalStartApplication(): canStart==false; cannot auto locate an office suite installation. So we must search manually..."); //we must search manually } System.out.println( "NOAUIPlugin: internalStartApplication(): configurationCompleted=" + configurationCompleted); if (!configurationCompleted) { LocalApplicationWizard localApplicationWizard = new LocalApplicationWizard(applicationInfos); if (home != null && home.length() != 0) localApplicationWizard.setHomePath(home); WizardDialog wizardDialog = new WizardDialog(shell, localApplicationWizard); if (wizardDialog.open() == Window.CANCEL) return Status.CANCEL_STATUS; configuration.put(IOfficeApplication.APPLICATION_HOME_KEY, localApplicationWizard.getSelectedHomePath()); } } System.out.println( "NOAUIPlugin: internalStartApplication(): the office suite configuration should now be valid:"); if (officeApplication == null) System.out.println("NOAUIPlugin: internalStartApplication(): officeApplication==null"); else System.out.println( "NOAUIPlugin: internalStartApplication(): officeApplication=" + officeApplication.toString()); if (configuration == null) System.out.println("NOAUIPlugin: internalStartApplication(): configuration==null"); else System.out .println("NOAUIPlugin: internalStartApplication(): configuration=" + configuration.toString()); if (shell == null) System.out.println("NOAUIPlugin: internalStartApplication(): shell==null"); else System.out.println("NOAUIPlugin: internalStartApplication(): shell=" + shell.toString()); System.out.println( "NOAUIPlugin: internalStartApplication(): Finally trying activateOfficeApplication(officeApplication, configuration, shell):"); IStatus status = activateOfficeApplication(officeApplication, configuration, shell); if (configurationChanged) { System.out.println( "NOAUIPlugin: internalStartApplication(): Configuration of PREFERENCE_OFFICE_HOME changed."); System.out.println("NOAUIPlugin: internalStartApplication(): Storing the new configuration."); System.out.println( "NOAUIPlugin: internalStartApplication(): Using js mod adopted for Elexis, reproducing prior GW adoptions, P_OOBASEDIR via ...(Hub.localCfg)"); //JS modified this: //The original code tries to access a preference store which is not used in Elexis, //according to GWs mods in (back then:) LocalOfficeApplicationPreferencesPage.java //Unsuitable original line, removed: //getDefault().getPluginPreferences().setValue(PREFERENCE_OFFICE_HOME, // configuration.get(IOfficeApplication.APPLICATION_HOME_KEY).toString()); //Newly inserted line: preferenceStore.setValue(PreferenceConstants.P_OOBASEDIR, configuration.get(IOfficeApplication.APPLICATION_HOME_KEY).toString()); } System.out.println("NOAUIPlugin: internalStartApplication() end, returning status"); return status; }
From source file:ar.com.tadp.xml.rinzo.jdt.preferences.ClassAttribute.java
License:Open Source License
public static List<ClassAttribute> loadFromPreference(boolean defaults) { IPreferenceStore store = RinzoJDTPlugin.getDefault().getPreferenceStore(); String value = null;//from w ww. j a v a2 s . co m if (defaults) { value = store.getDefaultString(RinzoJDTPlugin.PREF_CLASSNAME_ATTRS); } else { value = store.getString(RinzoJDTPlugin.PREF_CLASSNAME_ATTRS); } List<ClassAttribute> list = new ArrayList<ClassAttribute>(); if (value != null) { String[] values = value.split("\n"); for (int i = 0; i < values.length; i++) { String[] split = values[i].split(FileUtils.TAB); if (split.length == 3) { list.add(new ClassAttribute(split[0], split[1], split[2])); } } } return list; }