List of usage examples for org.eclipse.jface.preference IPreferenceStore getString
String getString(String name);
From source file:ccw.preferences.OverlayPreferenceStore.java
License:Open Source License
private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) { TypeDescriptor d = key.fDescriptor;/* w w w .j a va2s . c o m*/ if (BOOLEAN == d) { if (forceInitialization) target.setValue(key.fKey, true); target.setValue(key.fKey, orgin.getBoolean(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey)); } else if (DOUBLE == d) { if (forceInitialization) target.setValue(key.fKey, 1.0D); target.setValue(key.fKey, orgin.getDouble(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey)); } else if (FLOAT == d) { if (forceInitialization) target.setValue(key.fKey, 1.0F); target.setValue(key.fKey, orgin.getFloat(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey)); } else if (INT == d) { if (forceInitialization) target.setValue(key.fKey, 1); target.setValue(key.fKey, orgin.getInt(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey)); } else if (LONG == d) { if (forceInitialization) target.setValue(key.fKey, 1L); target.setValue(key.fKey, orgin.getLong(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey)); } else if (STRING == d) { if (forceInitialization) target.setValue(key.fKey, "1"); //$NON-NLS-1$ target.setValue(key.fKey, orgin.getString(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); } }
From source file:ch.elexis.omnivore.data.Utils.java
License:Open Source License
static private String processFileElement(IPreferenceStore preferenceStore, String element_key, String element_data) {/* w w w. j a v a 2 s. c o m*/ log.debug("processFileElement: element_key=<{}> data <{}>", element_key, element_data); StringBuffer element_data_processed = new StringBuffer(); Integer nCotfRules = Preferences.PREFERENCE_cotf_elements.length; for (int i = 0; i < nCotfRules; i++) { if (Preferences.PREFERENCE_cotf_elements[i].equals(element_key)) { if (element_key.contains("constant")) { String search = PREFBASE + Preferences.PREFERENCE_COTF + Preferences.PREFERENCE_cotf_elements[i] + "_" + Preferences.PREFERENCE_cotf_parameters[1]; String constant = preferenceStore.getString(search).trim(); log.debug("processFileElement: {} returning constant=<{}>", search, constant); if (constant.length() > 0) log.debug("processFileElement: {} returning constant=<{}>", search, 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 snumId = PREFBASE + Preferences.PREFERENCE_COTF + Preferences.PREFERENCE_cotf_elements[i] + "_" + Preferences.PREFERENCE_cotf_parameters[1]; String snum_digits = preferenceStore.getString(snumId).trim(); // 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 > Preferences.nPreferences_cotf_element_digits_max) { num_digits = Preferences.nPreferences_cotf_element_digits_max; } // Remove all characters that shall not appear in the generated filename String element_data_processed5 = (element_data .replaceAll(java.util.regex.Matcher.quoteReplacement(Preferences.cotf_unwanted_chars), "") .toString().trim()); // filter out some special unwanted strings from the title that may have eeclipse-javadoc:%E2%98%82=ch.elexis.core.data/%5C/usr%5C/lib%5C/jvm%5C/java-8-oracle%5C/jre%5C/lib%5C/rt.jar%3Cjava.util.regex(Matcher.class%E2%98%83Matcher~quoteReplacement~Ljava.lang.String;%E2%98%82java.lang.Stringntered // 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 // 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); } // 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. String leadId = PREFBASE + Preferences.PREFERENCE_COTF + Preferences.PREFERENCE_cotf_elements[i] + "_" + Preferences.PREFERENCE_cotf_parameters[0]; String lead_fill_char = preferenceStore.getString(leadId).trim(); 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); for (int n = element_data_processed1.length(); n <= num_digits; n++) { element_data_processed.append(lead_fill_char); } } element_data_processed.append(element_data_processed1); // If an add trailing character is given, add one (typically, this would be a // space or an underscore) String trailId = PREFBASE + Preferences.PREFERENCE_COTF + Preferences.PREFERENCE_cotf_elements[i] + "_" + Preferences.PREFERENCE_cotf_parameters[2]; String add_trail_char = preferenceStore.getString(trailId).trim(); if ((add_trail_char != null) && (add_trail_char.length() > 0)) { add_trail_char = add_trail_char.substring(0, 1); element_data_processed.append(add_trail_char); } log.debug("{} {} {} {} <{}> {} <{>}", i, snumId, snum_digits, leadId, lead_fill_char, trailId, add_trail_char); } log.debug("processFileElement: 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:ch.elexis.omnivore.ui.preferences.PreferencePage.java
License:Open Source License
public static String getOmnivoreTemp_Filename_Element(IPreferenceStore preferenceStore, String element_key, String element_data) {/*from w ww .j a va 2 s .c om*/ log.debug("getOmnivoreTemp_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++) { log.debug("getOmnivoreTemp_Filename_Element: PREFERENCE_cotf_elements[" + i + "]=<" + PREFERENCE_cotf_elements[i] + ">"); if (PREFERENCE_cotf_elements[i].equals(element_key)) { log.debug("getOmnivoreTemp_Filename_Element: Match!"); if (element_key.contains("constant")) { String constant = preferenceStore.getString(PREFBASE + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[1]).trim(); log.debug("getOmnivoreTemp_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(PREFBASE + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[1]).trim(); log.debug("getOmnivoreTemp_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 > nPreferences_cotf_element_digits_max) { num_digits = nPreferences_cotf_element_digits_max; } log.debug("getOmnivoreTemp_Filename_Element: num_digits=<" + num_digits + ">"); // Start with the passed element_data string String element_data_incoming = element_data.trim(); log.debug("getOmnivoreTemp_Filename_Element: element_data_incoming=<" + element_data_incoming + ">"); // Remove all characters that shall not appear in the generated filename // Ich verwende kein replaceAll, weil dessen Implementation diverse // erforderliche Escapes offenbar nicht erlaubt. // Especially, \. is not available to specify a plain dot. (Na ja: \0x2e ginge // dann doch - oder sollte gehen. // Findet aber nichts. Im interaktiven Suchen/Ersetzen in Eclipse ist \0x2e // illegal; \x2e geht eher. // In Java Code geht ggf. \056 (octal) . Siehe unten beim automatischen // Entfernen von Dateinamen-Resten besonders aus dem docTitle.)) StringBuffer element_data_clean = new StringBuffer(); if (element_data_incoming != null) { for (int n = 0; n < element_data_incoming.length(); n++) { String c = element_data_incoming.substring(n, n + 1); if ((c.codePointAt(0) >= 32) && (!cotf_unwanted_chars.contains(c))) { element_data_clean.append(c); } } } String element_data_processed5 = (element_data_clean.toString().trim()); log.debug("getOmnivoreTemp_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 log.debug("getOmnivoreTemp_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); } log.debug("getOmnivoreTemp_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. String lead_fill_char = preferenceStore.getString(PREFBASE + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[0]).trim(); log.debug("getOmnivoreTemp_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); log.debug("getOmnivoreTemp_Filename_Element: lead_fill_char=<" + lead_fill_char + ">"); log.debug("getOmnivoreTemp_Filename_Element: num_digits=<" + num_digits + ">"); log.debug("getOmnivoreTemp_Filename_Element: element_data_processed1.length()=<" + element_data_processed1.length() + ">"); log.debug("getOmnivoreTemp_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); log.debug("getOmnivoreTemp_Filename_Element: n, element_data_processed=" + n + ", <" + element_data_processed + ">"); } } element_data_processed.append(element_data_processed1); log.debug("getOmnivoreTemp_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) String add_trail_char = preferenceStore.getString(PREFBASE + PREFERENCE_COTF + PREFERENCE_cotf_elements[i] + "_" + PREFERENCE_cotf_parameters[2]).trim(); log.debug("getOmnivoreTemp_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); log.debug("getOmnivoreTemp_Filename_Element: add_trail_char=<" + add_trail_char + ">"); element_data_processed.append(add_trail_char); log.debug("getOmnivoreTemp_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:ch.elexis.preferences.PreferenceInitializer.java
License:Open Source License
/** * Diese Funktion wird automatisch beim Programmstart aufgerufen, und setzt alle hier * definierten Einstellungswerte auf Voreinstellungen, sofern noch keine vom Anwender erstellten * Werte vorhanden sind. Hier alle Benutzerspezifischen Voreinstellungen eintragen *//* w ww. ja v a2 s . com*/ public void initializeDefaultPreferences() { IPreferenceStore localstore = new SettingsPreferenceStore(Hub.localCfg); // Datenbank /* * localstore.setDefault(PreferenceConstants.DB_NAME,"hsql"); //$NON-NLS-1$ * localstore.setDefault(PreferenceConstants.DB_CLASS,"org.hsqldb.jdbcDriver"); * //$NON-NLS-1$ String base=getDefaultDBPath(); * * localstore.setDefault(PreferenceConstants.DB_CONNECT,"jdbc:hsqldb:"+base+"/db"); * //$NON-NLS-1$ //$NON-NLS-2$ localstore.setDefault(PreferenceConstants.DB_USERNAME,"sa"); * //$NON-NLS-1$ localstore.setDefault(PreferenceConstants.DB_PWD,""); //$NON-NLS-1$ * localstore.setDefault(PreferenceConstants.DB_TYP,"hsqldb"); //$NON-NLS-1$ */ localstore.setDefault(PreferenceConstants.DB_NAME, "h2"); //$NON-NLS-1$ //localstore.setDefault(PreferenceConstants.DB_CLASS,"org.h2.Driver"); //$NON-NLS-1$ String base = getDefaultDBPath(); localstore.setDefault(PreferenceConstants.DB_CONNECT, "jdbc:h2:" + base + "/db;MODE=MySQL"); //$NON-NLS-1$ //$NON-NLS-2$ localstore.setDefault(PreferenceConstants.DB_USERNAME, "sa"); //$NON-NLS-1$ localstore.setDefault(PreferenceConstants.DB_PWD, ""); //$NON-NLS-1$ localstore.setDefault(PreferenceConstants.DB_TYP, "mysql"); //$NON-NLS-1$ // Ablauf File userhome = new File(System.getProperty("user.home") + File.separator + "elexis"); //$NON-NLS-1$ //$NON-NLS-2$ if (!userhome.exists()) { userhome.mkdirs(); } localstore.setDefault(PreferenceConstants.ABL_LOGALERT, 1); localstore.setDefault(PreferenceConstants.ABL_LOGLEVEL, 2); localstore.setDefault(PreferenceConstants.ABL_TRACE, "none"); //$NON-NLS-1$ localstore.setDefault(PreferenceConstants.ABL_BASEPATH, userhome.getAbsolutePath()); localstore.setDefault(PreferenceConstants.ABL_CACHELIFETIME, PersistentObject.CACHE_DEFAULT_LIFETIME); localstore.setDefault(PreferenceConstants.ABL_HEARTRATE, 30); Hub.localCfg.set(PreferenceConstants.ABL_BASEPATH, userhome.getAbsolutePath()); // Texterstellung if (System.getProperty("os.name").toLowerCase().startsWith("win")) { //$NON-NLS-1$ //$NON-NLS-2$ localstore.setDefault(PreferenceConstants.P_TEXTMODUL, "NOA-Text"); //$NON-NLS-1$ if (localstore.getString(PreferenceConstants.P_TEXTMODUL).equals(StringTool.leer)) { localstore.setValue(PreferenceConstants.P_TEXTMODUL, "NOA-Text"); //$NON-NLS-1$ } } else { localstore.setDefault(PreferenceConstants.P_TEXTMODUL, "OpenOffice Wrapper"); //$NON-NLS-1$ if (localstore.getString(PreferenceConstants.P_TEXTMODUL).equals("")) { //$NON-NLS-1$ localstore.setValue(PreferenceConstants.P_TEXTMODUL, "OpenOffice Wrapper"); //$NON-NLS-1$ } } File elexisbase = new File(Hub.getBasePath()); File fDef = new File(elexisbase.getParentFile().getParent() + "/ooo"); //$NON-NLS-1$ String defaultbase; if (fDef.exists()) { defaultbase = fDef.getAbsolutePath(); } else { defaultbase = Hub.localCfg.get(PreferenceConstants.P_OOBASEDIR, "."); //$NON-NLS-1$ } System.setProperty("openoffice.path.name", defaultbase); //$NON-NLS-1$ localstore.setDefault(PreferenceConstants.P_OOBASEDIR, defaultbase); localstore.setValue(PreferenceConstants.P_OOBASEDIR, defaultbase); // Dokument StringBuilder sb = new StringBuilder(); sb.append("Alle,").append(Brief.UNKNOWN).append(",").append(Brief.AUZ).append(",") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ .append(Brief.RP).append(",").append(Brief.LABOR); //$NON-NLS-1$ localstore.setDefault(PreferenceConstants.DOC_CATEGORY, sb.toString()); Hub.localCfg.flush(); }
From source file:ch.netcetera.eclipse.projectconfig.ui.handler.ProjectStettingsPropertyTester.java
License:Open Source License
/** * {@inheritDoc}//from w w w . ja v a2 s . co m */ @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (URL_CONFIGURED.equals(property)) { IPreferenceStore preferences = ProjectConfigurationUIPlugin.getDefault().getPreferenceStore(); String url = preferences.getString(ProjectConfigurationUIPlugin.CONFIG_CMDFILE_URL); return url.length() > 0 == toBoolean(expectedValue); } return false; }
From source file:ch.netcetera.eclipse.projectconfig.ui.handler.RunProjectConfigurationScriptHandler.java
License:Open Source License
/** * Gets the script URL from the preferences and prompts the user a choice of more than one URL is * configured./*from w w w . j a v a2 s .c o m*/ * * @return the URL of the project configuration script to run */ private String getScriptURL() { IPreferenceStore preferenceStore = ProjectConfigurationUIPlugin.getDefault().getPreferenceStore(); List<String> urls = PreferenceListSquasher.splitListItemsToStringArray( preferenceStore.getString(ProjectConfigurationUIPlugin.CONFIG_CMDFILE_URL)); String scriptUrl = ""; // only one url configured --> no selection dialog if (urls.size() == 1) { scriptUrl = urls.get(0); // multiple urls configured --> display selection dialog } else if (urls.size() > 1) { ComboSelectionDialog selectionDialog = new ComboSelectionDialog( ProjectConfigurationUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), ProjectConfigurationUIPlugin.getDefault().getText("apply.config.dialog.title"), ProjectConfigurationUIPlugin.getDefault().getText("apply.config.dialog.label"), urls, 0); selectionDialog.open(); if (selectionDialog.getReturnCode() == Window.OK) { scriptUrl = selectionDialog.getSelectedString(); } } return scriptUrl; }
From source file:ch.qos.logback.beagle.view.TableMediator.java
License:Open Source License
private void initConverterFacade() { converterFacade.setContext(loggerContext); String pattern = BeaglePreferencesPage.PATTERN_PREFERENCE_DEFAULT_VALUE; if (Activator.INSTANCE != null) { IPreferenceStore pStore = Activator.INSTANCE.getPreferenceStore(); pattern = pStore.getString(BeaglePreferencesPage.PATTERN_PREFERENCE); }//from w w w . j a v a 2 s.co m converterFacade.setPattern(pattern); converterFacade.start(); }
From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.CloudUiUtil.java
License:Open Source License
public static List<CloudServerURL> getUserDefinedUrls(String serverTypeId) { List<CloudServerURL> urls = new ArrayList<CloudServerURL>(); Preferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID); try {// w w w.j ava2 s . co m String[] childrenNames = preferences.childrenNames(); if (childrenNames != null) { for (int i = 0; i < childrenNames.length; i++) { Preferences sub1 = preferences.node(childrenNames[i]); String name = sub1.get("name", ""); boolean isUseDefault = sub1.getBoolean("isUseDefault", true); boolean isUseUnixSocket = sub1.getBoolean("isUseUnixSocket", false); String socketPath = sub1.get("socketPath", ""); boolean isUseHTTPS = sub1.getBoolean("isUseHTTPS", false); String host = sub1.get("host", ""); boolean isEnableAuth = sub1.getBoolean("isEnableAuth", false); String authPath = sub1.get("authPath", ""); DockerConnectionElement connElem = new DockerConnectionElement(); connElem.setAuthPath(authPath); connElem.setEnableAuth(isEnableAuth); connElem.setHost(host); connElem.setName(name); connElem.setSocketPath(socketPath); connElem.setUseDefault(isUseDefault); connElem.setUseHTTPS(isUseHTTPS); connElem.setUseUnixSocket(isUseUnixSocket); String connName = ""; if (connElem.isUseDefault()) { connName += "Default"; } else if (connElem.isUseHTTPS()) { connName += connElem.getHost(); } urls.add(new CloudServerURL(name, connName, true, null, connElem)); } } } catch (BackingStoreException e) { e.printStackTrace(); } IPreferenceStore prefStore = DockerFoundryServerUiPlugin.getDefault().getPreferenceStore(); String urlString = prefStore.getString(ATTR_USER_DEFINED_URLS + "." + serverTypeId); //$NON-NLS-1$ if (urlString != null && urlString.length() > 0) { // Split on "||" String[] urlEntries = urlString.split("\\|\\|"); //$NON-NLS-1$ if (urlEntries != null) { for (String entry : urlEntries) { if (entry.length() > 0) { String[] values = entry.split(","); //$NON-NLS-1$ if (values != null) { String name = null; String url = null; if (values.length >= 2) { name = values[0]; url = values[1]; } urls.add(new CloudServerURL(name, url, true)); } } } } } return urls; }
From source file:com.abstratt.mdd.internal.ui.TextUMLUIPlugin.java
License:Open Source License
public boolean isPreferencePresentInEditorOptions(String preference) { boolean result = false; IPreferenceStore store = getPreferenceStore(); String rawString = store.getString(OPTIONS); if (rawString != null && !rawString.equals("") && rawString.contains(preference)) { return true; }//w w w . j a v a2s. co m return result; }
From source file:com.aerospike.aql.plugin.actions.GenerateSource.java
License:Apache License
public void run(IAction action) { if (selection != null && selection instanceof TreeSelection) { TreeSelection ts = (TreeSelection) selection; Object element = ts.getFirstElement(); if (element instanceof IFile && ((IFile) element).getFileExtension().equalsIgnoreCase("aql")) { final IFile sqlFile = (IFile) element; if (sqlFile == null) return; try { final List<String> errorList = new ArrayList<String>(); final String actionID = action.getId(); final AQLResult results = new AQLResult(); // find the Aerospike console and display it IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win.getActivePage(); IConsoleView view = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW); view.display(results.getConsole()); // set generation language String extension; final com.aerospike.aql.AQL.Language language; if (actionID.equals("com.aerospike.aql.plugin.actions.GenerateSource.java.popup")) { language = com.aerospike.aql.AQL.Language.JAVA; extension = ".java"; } else if (actionID.equals("com.aerospike.aql.plugin.actions.GenerateSource.c.popup")) { language = com.aerospike.aql.AQL.Language.C; extension = ".c"; } else if (actionID.equals("com.aerospike.aql.plugin.actions.GenerateSource.csharp.popup")) { language = com.aerospike.aql.AQL.Language.CSHARP; extension = ".csharp"; } else { return; }//from w w w .j ava2s . com IProject project = sqlFile.getProject(); IPath outputPath; String sqlFileName = sqlFile.getName(); String outputFileName = sqlFileName.substring(0, sqlFileName.lastIndexOf('.')) + extension; final AsCluster cluster = (AsCluster) project .getSessionProperty(CoreActivator.CLUSTER_PROPERTY); String outputDirectoryString = project .getPersistentProperty(CoreActivator.AQL_GENERATION_DIRECTORY); if (outputDirectoryString == null || outputDirectoryString.isEmpty()) { outputPath = project.getLocation().append(outputFileName); } else { IPath dirPath = project.getLocation().append(outputDirectoryString); if (!dirPath.toFile().exists()) dirPath.toFile().mkdirs(); outputPath = dirPath.append(outputFileName); } final File outputFile = outputPath.toFile(); IPath location = sqlFile.getLocation(); final File file = location.toFile(); final IFile outputIFile = project.getWorkspace().getRoot().getFileForLocation(outputPath); Job job = new Job("Generate source code from AQL: " + sqlFile.getName()) { @Override protected IStatus run(IProgressMonitor monitor) { AQL aql = new AQL(); try { String seedNode = ""; int port = 3000; if (cluster != null) { seedNode = cluster.getSeedHost(); port = cluster.getPort(); } else { IPreferenceStore store = CoreActivator.getDefault().getPreferenceStore(); seedNode = store.getString(PreferenceConstants.SEED_NODE); port = store.getInt(PreferenceConstants.PORT); } aql.compileAndGenerate(file, outputFile, language, seedNode, port); results.report("Completed generation for " + sqlFile.getName()); outputIFile.getParent().refreshLocal(IResource.DEPTH_ONE, null); return Status.OK_STATUS; } catch (Exception e) { CoreActivator.showError(e, COULD_NOT_GENERATE_CODE_FROM_SQL_FILE + sqlFile.getName()); return Status.CANCEL_STATUS; } } }; job.setUser(true); job.schedule(); } catch (PartInitException e) { CoreActivator.showError(e, COULD_NOT_GENERATE_CODE_FROM_SQL_FILE + sqlFile.getName()); } catch (CoreException e) { CoreActivator.showError(e, COULD_NOT_GENERATE_CODE_FROM_SQL_FILE + sqlFile.getName()); } } } }