List of usage examples for org.eclipse.jface.preference IPreferenceStore getInt
int getInt(String name);
From source file:com.bdaum.zoom.ai.clarifai.internal.preference.PagePart.java
License:Open Source License
@Override public void fillValues() { clientIdField.removeModifyListener(this); clientSecretField.removeModifyListener(this); IPreferenceStore preferenceStore = getPreferenceStore(); clientIdField.setText(preferenceStore.getString(PreferenceConstants.CLIENTID)); clientSecretField.setText(preferenceStore.getString(PreferenceConstants.CLIENTSECRET)); conceptField.setSelection(preferenceStore.getInt(PreferenceConstants.MAXCONCEPTS)); confidenceField.setSelection(preferenceStore.getInt(PreferenceConstants.MINCONFIDENCE)); aboveField.setSelection(preferenceStore.getInt(PreferenceConstants.MARKABOVE)); knownButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.MARKKNOWNONLY)); adultButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.ADULTCONTENTS)); faceButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.FACES)); celebrityButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.CELEBRITIES)); translateButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.TRANSLATE)); ClarifaiActivator activator = ClarifaiActivator.getDefault(); activator.setAccountCredentials(clientIdField.getText().trim(), clientSecretField.getText().trim()); verifyAccountCredenials(100);// w w w .j ava 2 s . co m modelCombo.setSelection(new StructuredSelection(ClarifaiActivator.getDefault().getTheme())); currentLanguage = preferenceStore.getString(PreferenceConstants.LANGUAGE); languageCombo.setSelection(new StructuredSelection(currentLanguage)); clientIdField.addModifyListener(this); clientSecretField.addModifyListener(this); }
From source file:com.bdaum.zoom.ai.msvision.internal.core.MsVisionServiceProvider.java
License:Open Source License
public Prediction predict(byte[] jpeg) { Prediction prediction = null;/*from ww w. j a v a 2s . c o m*/ MsVisionActivator activator = MsVisionActivator.getDefault(); VisionServiceRestClient client = activator.getClient(); List<String> features = new ArrayList<>(); features.add("Categories"); //$NON-NLS-1$ features.add("Tags"); //$NON-NLS-1$ if (generateDescription()) features.add("Description"); //$NON-NLS-1$ if (checkFaces()) features.add("Faces"); //$NON-NLS-1$ if (checkAdultContent()) features.add("Adult"); //$NON-NLS-1$ String[] details = checkCelebrities() ? CELEBRITIES : EMPTY; try (InputStream stream = new ByteArrayInputStream(jpeg)) { AnalysisResult analysisResult = client.analyzeImage(stream, features.toArray(new String[features.size()]), details); IPreferenceStore preferenceStore = activator.getPreferenceStore(); int maxConcepts = preferenceStore.getInt(PreferenceConstants.MAXCONCEPTS); float minConfidence = preferenceStore.getInt(PreferenceConstants.MINCONFIDENCE) * 0.01f; List<Token> cats = new ArrayList<>(); List<Category> categories = analysisResult.categories; if (categories != null) for (Category category : categories) cats.add(new Token(CategoryMessages.getString(category.name), (float) category.score)); if (cats.size() >= maxConcepts) cats = cats.subList(0, maxConcepts); Collections.sort(cats, TokenComparator.INSTANCE); List<Token> keywords = new ArrayList<>(); List<Tag> tags = analysisResult.tags; if (tags != null) for (Tag tag : tags) { double score = tag.confidence; if (score >= minConfidence) keywords.add(new Token(tag.name, (float) score)); } if (keywords.size() >= maxConcepts) keywords = keywords.subList(0, maxConcepts); Collections.sort(keywords, TokenComparator.INSTANCE); boolean trCats = preferenceStore.getBoolean(PreferenceConstants.TRANSLATE_CATEGORIES) && !cats.isEmpty(); boolean trTags = preferenceStore.getBoolean(PreferenceConstants.TRANSLATE_TAGS) && !keywords.isEmpty(); if (trCats || trTags) { TranslatorClient translatorClient = AiActivator.getDefault().getClient(); if (translatorClient != null) { StringBuilder sb = new StringBuilder(); if (trCats) { for (Token tok : cats) { if (sb.length() > 0) sb.append(", "); //$NON-NLS-1$ sb.append(tok.getLabel()); } } if (trTags && trCats) sb.append(" : "); //$NON-NLS-1$ int l = sb.length(); if (trTags) { for (Token tok : keywords) { if (sb.length() > l) sb.append(", "); //$NON-NLS-1$ sb.append(tok.getLabel()); } } String translate = translatorClient.translate(sb.toString()); String translatedCats = null; String translatedTags = null; if (trTags) { if (trCats) { int p = translate.indexOf(':'); if (p >= 0) { translatedCats = translate.substring(0, p); translatedTags = translate.substring(p + 1); } else translatedCats = translate; } else translatedTags = translate; } else if (trCats) translatedCats = translate; applyTranslation(translatedCats, cats); applyTranslation(translatedTags, keywords); } } prediction = new Prediction(SERVICENAME, cats.toArray(new Token[cats.size()]), keywords.toArray(new Token[keywords.size()]), Status.OK_STATUS); if (generateDescription()) { Description description = analysisResult.description; if (description != null) { List<Caption> captions = description.captions; if (!captions.isEmpty()) { List<Token> descriptions = new ArrayList<>(captions.size()); for (Caption caption : captions) descriptions.add(new Token(caption.text, (float) caption.confidence)); Collections.sort(descriptions, TokenComparator.INSTANCE); String descr = descriptions.get(0).getLabel(); if (preferenceStore.getBoolean(PreferenceConstants.TRANSLATE_DESCRIPTION)) { TranslatorClient translatorClient = AiActivator.getDefault().getClient(); if (translatorClient != null) descr = translatorClient.translate(descr); } if (descr.length() > 1) descr = Character.toUpperCase(descr.charAt(0)) + descr.substring(1); prediction.setDescription(descr); } } } if (checkFaces()) { List<Rectangle> rects = new ArrayList<>(); List<Face> faces = analysisResult.faces; if (faces != null) for (Face face : faces) { FaceRectangle faceRectangle = face.faceRectangle; rects.add(new Rectangle(faceRectangle.left, faceRectangle.top, faceRectangle.width, faceRectangle.height)); } prediction.setFaces(rects); } if (checkAdultContent()) { Adult adult = analysisResult.adult; boolean isAdultContent = adult != null && adult.isAdultContent; boolean isRacyContent = adult != null && adult.isRacyContent; prediction.setSafeForWork(isAdultContent ? 0f : 1f, isRacyContent ? 0f : 1f); } return prediction; } catch (VisionServiceException e) { return new Prediction(SERVICENAME, null, null, new Status(IStatus.ERROR, MsVisionActivator.PLUGIN_ID, Messages.MsVisionServiceProvider_ms_vision_exception, e)); } catch (IOException e) { return new Prediction(SERVICENAME, null, null, new Status(IStatus.ERROR, MsVisionActivator.PLUGIN_ID, Messages.MsVisionServiceProvider_ms_vision_io_error, e)); } }
From source file:com.bdaum.zoom.ai.msvision.internal.preference.PagePart.java
License:Open Source License
@Override public void fillValues() { keyField.removeModifyListener(this); IPreferenceStore preferenceStore = getPreferenceStore(); keyField.setText(preferenceStore.getString(PreferenceConstants.KEY)); conceptField.setSelection(preferenceStore.getInt(PreferenceConstants.MAXCONCEPTS)); confidenceField.setSelection(preferenceStore.getInt(PreferenceConstants.MINCONFIDENCE)); aboveField.setSelection(preferenceStore.getInt(PreferenceConstants.MARKABOVE)); knownButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.MARKKNOWNONLY)); adultButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.ADULTCONTENTS)); faceButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.FACES)); celebrityButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.CELEBRITIES)); descriptionButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.DESCRIPTION)); translateDescriptionButton//from w w w . j a v a 2 s. c om .setSelection(preferenceStore.getBoolean(PreferenceConstants.TRANSLATE_DESCRIPTION)); translateCatButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.TRANSLATE_CATEGORIES)); translateTagButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.TRANSLATE_TAGS)); MsVisionActivator activator = MsVisionActivator.getDefault(); activator.setAccountCredentials(keyField.getText().trim()); verifyAccountCredenials(100); keyField.addModifyListener(this); updateButtons(); }
From source file:com.bdaum.zoom.gps.internal.preferences.GpsPreferencePage.java
License:Open Source License
@Override protected void doFillValues() { IPreferenceStore preferenceStore = getPreferenceStore(); altitudeButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.UPDATEALTITUDE)); coordinateButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.INCLUDECOORDINATES)); placenameButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.INCLUDENAMES)); editButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.EDIT)); tagButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.OVERWRITE)); waypointButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.USEWAYPOINTS)); timeShiftMinuteField.setSelection(preferenceStore.getInt(PreferenceConstants.TIMESHIFT)); toleranceHourField.setSelection(preferenceStore.getInt(PreferenceConstants.TOLERANCE) / 60); toleranceMinuteField.setSelection(preferenceStore.getInt(PreferenceConstants.TOLERANCE) % 60); GpsUtilities.getGeoAreas(preferenceStore, nogoAreas); nogoViewer.setInput(nogoAreas);//from ww w . j a va 2 s .com reqhField.setSelection(preferenceStore.getInt(PreferenceConstants.HOURLYLIMIT)); String nservice = preferenceStore.getString(PreferenceConstants.NAMINGSERVICE); setNamingServiceCombo(nservice); for (IGeocodingService service : GpsActivator.getDefault().getNamingServices()) for (Parameter parameter : service.getParameters()) { CheckedText field = keyMap.get(parameter.getId()); field.setText(preferenceStore.getString(parameter.getId())); field.setHint(parameter.getHint()); } }
From source file:com.bdaum.zoom.ui.internal.preferences.AppearancePreferencePage.java
License:Open Source License
@Override protected void doFillValues() { IPreferenceStore preferenceStore = getPreferenceStore(); theme = preferenceStore.getString(PreferenceConstants.BACKGROUNDCOLOR); colorViewer.setSelection(new StructuredSelection(theme)); distViewer/*from ww w .j a v a 2s .com*/ .setSelection(new StructuredSelection(preferenceStore.getString(PreferenceConstants.DISTANCEUNIT))); dimViewer.setSelection(new StructuredSelection(preferenceStore.getString(PreferenceConstants.DIMUNIT))); locationButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.SHOWLOCATION)); doneButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.SHOWDONEMARK)); regionField.setSelection(preferenceStore.getInt(PreferenceConstants.MAXREGIONS)); String rating = preferenceStore.getString(PreferenceConstants.SHOWRATING); int r = 1; for (int i = 0; i < ratingOptions.length; i++) if (ratingOptions[i].equals(rating)) { r = i; break; } showRatingGroup.setSelection(r); rotateButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.SHOWROTATEBUTTONS)); voiceNoteButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.SHOWVOICENOTE)); expandButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.SHOWEXPANDCOLLAPSE)); labelConfigGroup.setSelection(preferenceStore.getInt(PreferenceConstants.SHOWLABEL), preferenceStore.getString(PreferenceConstants.THUMBNAILTEMPLATE), preferenceStore.getInt(PreferenceConstants.LABELFONTSIZE)); updateButtons(); }
From source file:com.bdaum.zoom.ui.internal.preferences.GeneralPreferencePage.java
License:Open Source License
@Override protected void doFillValues() { IPreferenceStore preferenceStore = getPreferenceStore(); undoField.setSelection(preferenceStore.getInt(PreferenceConstants.UNDOLEVELS)); backupField.setSelection(preferenceStore.getInt(PreferenceConstants.BACKUPINTERVAL)); backupGenerationsField.setSelection( new StructuredSelection(preferenceStore.getString(PreferenceConstants.BACKUPGENERATIONS))); iccViewer/*from w w w . j a v a2 s .co m*/ .setSelection(new StructuredSelection(preferenceStore.getString(PreferenceConstants.COLORPROFILE))); customFile = preferenceStore.getString(PreferenceConstants.CUSTOMPROFILE); advancedButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.ADVANCEDGRAPHICS)); previewButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.PREVIEW)); noiseButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.ADDNOISE)); enlargeButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.ENLARGESMALL)); if (displayGroup != null) { String s = preferenceStore.getString(PreferenceConstants.SECONDARYMONITOR); displayGroup.setSelection( PreferenceConstants.MON_ALTERNATE.equals(s) ? 2 : Boolean.parseBoolean(s) ? 1 : 0); } inactivityField.setSelection(preferenceStore.getInt(PreferenceConstants.INACTIVITYINTERVAL)); updateViewer .setSelection(new StructuredSelection(preferenceStore.getString(PreferenceConstants.UPDATEPOLICY))); noProgressButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.NOPROGRESS)); }
From source file:com.bdaum.zoom.ui.internal.preferences.HoverPreferencePage.java
License:Open Source License
@Override protected void doFillValues() { Map<String, IHoverContribution> hoverContributions = UiActivator.getDefault().getHoverManager() .getHoverContributions();//www . j a v a 2s. co m for (IHoverContribution contrib : hoverContributions.values()) { String cat = contrib.getCategory(); Category root = rootMap.get(cat); if (root == null) rootMap.put(cat, root = new Category(cat)); root.add(new HoverNode(contrib, root)); } viewer.setInput(rootMap.values().toArray()); viewer.expandAll(); IPreferenceStore preferenceStore = getPreferenceStore(); delayTimeField.setSelection(preferenceStore.getInt(PreferenceConstants.HOVERDELAY)); baseTimeField.setSelection(preferenceStore.getInt(PreferenceConstants.HOVERBASETIME)); charTimeField.setSelection(preferenceStore.getInt(PreferenceConstants.HOVERCHARTIME)); updateButtons(); super.doFillValues(); }
From source file:com.bdaum.zoom.ui.internal.preferences.ImportPreferencePage.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w . java 2 s . co m protected void doFillValues() { BatchActivator batch = BatchActivator.getDefault(); IRawConverter rc = batch.getCurrentRawConverter(false); previousRawConverter = rc; IPreferenceStore preferenceStore = getPreferenceStore(); Map<String, IRawConverter> rawConverters = batch.getRawConverters(); if (rc != null) rcViewer.setSelection(new StructuredSelection(rc)); for (IRawConverter c : rawConverters.values()) { FileEditor fileEditor = basicsFileEditors.get(c.getId()); if (fileEditor != null) { String path = preferenceStore.getString(c.getPathId()); if (path.isEmpty()) { String editorName = c.getName(); if (editorName != null) { FileEditorMapping editorMapping = null; for (String rf : ImageConstants.getRawFormatMap().keySet()) { editorMapping = UiActivator.getDefault().getFileEditorMapping(rf); if (editorMapping != null) break; } if (editorMapping != null) for (EditorDescriptor editorDescriptor : editorMapping.getEditors()) if (editorName.equalsIgnoreCase(editorDescriptor.getLabel())) { path = editorDescriptor.getFileName(); break; } } } fileEditor.setText(path); } for (IRawConverter.RawProperty prop : c.getProperties()) { prop.value = preferenceStore.getString(prop.id); Object object = optionProps.get(prop.id); if (object instanceof ComboViewer) { ComboViewer viewer = (ComboViewer) object; for (RawEnum rawEnum : (List<RawEnum>) viewer.getInput()) if (rawEnum.id.equals(prop.value)) { viewer.setSelection(new StructuredSelection(rawEnum)); if (rawEnum.recipe) { c.setUsesRecipes(rawEnum.id); if (c == rc) previousUsesRecipes = rawEnum.id; } break; } } else if (object instanceof Spinner) try { ((Spinner) object).setSelection(Integer.parseInt(prop.value)); } catch (NumberFormatException e) { // do nothing } else if (object instanceof Button) ((Button) object).setSelection(Boolean.parseBoolean(prop.value)); else if (object instanceof Text) ((Text) object).setText(prop.value); } } if (modeviewer != null) modeviewer.setSelection( new StructuredSelection(preferenceStore.getString(PreferenceConstants.RAWIMPORT))); if (dngpathEditor != null) dngpathEditor.setText(preferenceStore.getString(PreferenceConstants.DNGCONVERTERPATH)); if (uncompressedButton != null) uncompressedButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.DNGUNCOMPRESSED)); if (linearButton != null) linearButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.DNGLINEAR)); if (dngfolderField != null) dngfolderField.setText(preferenceStore.getString(PreferenceConstants.DNGFOLDER)); maxSpinner.setSelection(preferenceStore.getInt(PreferenceConstants.MAXIMPORTS)); String s = preferenceStore.getString(PreferenceConstants.DEVICEWATCH); deviceGroup.setSelection(PreferenceConstants.TETHERED.equals(s) ? 2 : Boolean.parseBoolean(s) ? 1 : 0); int tetheredShow = preferenceStore.getInt(PreferenceConstants.TETHEREDSHOW); tetheredGroup.setSelection(tetheredShow); showButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.SHOWIMPORTED)); makerNotesButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.IMPORTMAKERNOTES)); faceDataButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.IMPORTFACEDATA)); if (recipeViewer != null) { List<String> configurations = Core.fromStringList( preferenceStore.getString(PreferenceConstants.RECIPEDETECTORCONFIGURATIONS), "\n"); //$NON-NLS-1$ if (configurations != null && allDetectors != null) for (String conf : configurations) { int p = conf.indexOf(':'); if (p > 0) { String id = conf.substring(0, p); for (IRecipeDetector detector : allDetectors) { if (detector.getId().equals(id)) { StringTokenizer st = new StringTokenizer(conf.substring(p + 1), ";"); //$NON-NLS-1$ while (st.hasMoreTokens()) { String parm = st.nextToken(); int q = parm.indexOf('='); if (q > 0) { IRecipeParameter parameter = detector.getParameter(parm.substring(0, q)); if (parameter != null) parameter.setValue(parm.substring(q + 1)); } } break; } } } } selectedRecipeDetectors = Core .fromStringList(preferenceStore.getString(PreferenceConstants.RECIPEDETECTORS), "\n"); //$NON-NLS-1$ previousRecipeDetectors = new HashSet<String>(selectedRecipeDetectors); recipeViewer.setInput(allDetectors); previousProcessRecipes = preferenceStore.getBoolean(PreferenceConstants.PROCESSRECIPES); processRecipesButton.setSelection(previousProcessRecipes); archiveRecipesButton.setSelection(preferenceStore.getBoolean(PreferenceConstants.ARCHIVERECIPES)); } deviceGroup.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { checkForTetheringHint(); } }); }
From source file:com.bdaum.zoom.ui.internal.preferences.MousePreferencePage.java
License:Open Source License
@Override protected void doFillValues() { IPreferenceStore preferenceStore = getPreferenceStore(); speedScale.setSelection(preferenceStore.getInt(PreferenceConstants.MOUSE_SPEED)); wheelScale.setSelection(preferenceStore.getInt(PreferenceConstants.WHEELSOFTNESS)); zoomGroup.setSelection(preferenceStore.getInt(PreferenceConstants.ZOOMKEY)); }
From source file:com.bdaum.zoom.ui.internal.views.AbstractLightboxView.java
License:Open Source License
protected IPreferenceStore applyPreferences() { final IPreferenceStore preferenceStore = UiActivator.getDefault().getPreferenceStore(); showLabelDflt = preferenceStore.getInt(PreferenceConstants.SHOWLABEL); labelTemplateDflt = preferenceStore.getString(PreferenceConstants.THUMBNAILTEMPLATE); labelFontsizeDflt = preferenceStore.getInt(PreferenceConstants.LABELFONTSIZE); showRotateButtons = preferenceStore.getBoolean(PreferenceConstants.SHOWROTATEBUTTONS); showColorCode = !PreferenceConstants.COLORCODE_NO .equals(preferenceStore.getString(PreferenceConstants.SHOWCOLORCODE)); showLocation = preferenceStore.getBoolean(PreferenceConstants.SHOWLOCATION); String rating = preferenceStore.getString(PreferenceConstants.SHOWRATING); showRating = PreferenceConstants.SHOWRATING_NO.equals(rating) ? RATING_NO : PreferenceConstants.SHOWRATING_COUNT.equals(rating) ? RATING_COUNT : RATING_SIZE; showDoneMark = preferenceStore.getBoolean(PreferenceConstants.SHOWDONEMARK); showVoicenoteButton = preferenceStore.getBoolean(PreferenceConstants.SHOWVOICENOTE); showExpandCollapseButton = preferenceStore.getBoolean(PreferenceConstants.SHOWEXPANDCOLLAPSE); showRegions = preferenceStore.getInt(PreferenceConstants.MAXREGIONS); return preferenceStore; }