Java 类org.eclipse.jface.preference.JFacePreferences 实例源码

项目:javapasswordsafe    文件:UserPreferences.java   
/**
 * Loads preferences from a properties file.
 * 
 * @throws IOException if there are problems loading the preferences file
 */
private void loadPreferences() throws IOException {
    // props = new Properties();
    String userFile = getPreferencesFilename();
    if (log.isDebugEnabled())
        log.debug("Loading from [" + userFile + "]");
    File prefsFile = new File(userFile);
    if (!prefsFile.exists()) {
        File prefsDir = new File(System.getProperty("user.home") + File.separator + PROPS_DIR);
        if (!prefsDir.exists()) {
            prefsDir.mkdir();
        }
    }

    prefStore = new PreferenceStore(getPreferencesFilename());
    JFacePreferences.setPreferenceStore(prefStore);
    new JpwPreferenceInitializer().initializeDefaultPreferences();

    if (prefsFile.exists()) {
        prefStore.load();
    }
    // TODO: Check what happens if no file exists?

    if (log.isDebugEnabled())
        log.debug("Loaded " + prefStore + " preference settings from file");
}
项目:javapasswordsafe    文件:OpenUrlAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    PasswordSafeJFace app = PasswordSafeJFace.getApp();

    // TODO: this should check if URL is part of sparse fields
    PwsEntryBean selected = app.getSelectedRecord();
    if (selected == null || selected.getUrl() == null || selected.getUrl().length() == 0)
        return;

    IOUtils.openBrowser(selected.getUrl());

    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    final boolean recordAccessTime = thePrefs
            .getBoolean(JpwPreferenceConstants.RECORD_LAST_ACCESS_TIME);
    if (recordAccessTime) {// this could/should be sent to a background
                            // thread
        app.updateAccessTime(selected);
    }
}
项目:javapasswordsafe    文件:CopyPasswordAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    PasswordSafeJFace app = PasswordSafeJFace.getApp();

    PwsEntryBean selected = app.getSelectedRecord();
    if (selected == null)
        return;

    // retrieve filled Entry, always needed for passwords
    PwsEntryBean theEntry = app.getPwsDataStore().getEntry(selected.getStoreIndex());

    Clipboard cb = new Clipboard(app.getShell().getDisplay());

    app.copyToClipboard(cb, theEntry.getPassword().toString());

    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    final boolean recordAccessTime = thePrefs
            .getBoolean(JpwPreferenceConstants.RECORD_LAST_ACCESS_TIME);
    if (recordAccessTime) { // this could/should be sent to a background
                            // thread
        app.updateAccessTime(theEntry);
    }
    cb.dispose();
}
项目:javapasswordsafe    文件:AddRecordAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    PasswordSafeJFace app = PasswordSafeJFace.getApp();
    // TODO: Probably it will be simpler to call new PwsEntryBean();
    PwsEntryBean newEntry = PwsEntryBean.fromPwsRecord(app.getPwsFile().newRecord());
    IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    if (thePrefs.getBoolean(JpwPreferenceConstants.USE_DEFAULT_USERNAME)) {
        newEntry.setUsername(thePrefs.getString(JpwPreferenceConstants.DEFAULT_USERNAME));
    }
    if (app.isTreeViewShowing()) {
        // create new entry within existing group
        String selectedGroup = app.getSelectedTreeGroupPath();
        if (selectedGroup != null && selectedGroup.length() > 0) {
            newEntry.setGroup(selectedGroup);
        }
    }
    EditDialog ed = new EditDialog(app.getShell(), newEntry);
    newEntry = (PwsEntryBean) ed.open();
    if (newEntry != null) {
        newEntry.setSparse(false);
        app.addRecord(newEntry);
    }

}
项目:Eclipse-Postfix-Code-Completion    文件:PreferenceConstants.java   
/**
 * Initializes deprecated color constants.
 * 
 * @param store the preference store
 * @since 3.6
 */
private static void initializeDeprecatedColorConstants(IPreferenceStore store) {
    RGB bgRGB= null;
    RGB fgRGB= null;

    // Don't fail in headless mode
    if (PlatformUI.isWorkbenchRunning()) {
        bgRGB= JFaceResources.getColorRegistry().getRGB(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
        fgRGB= JFaceResources.getColorRegistry().getRGB(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
    }

    // Workaround for https://bugs.eclipse.org/306736
    if (bgRGB == null)
        bgRGB= new RGB(255, 255, 255);
    if (fgRGB == null)
        fgRGB= new RGB(0, 0, 0);

    setRGBValue(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, bgRGB);
    setRGBValue(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, fgRGB);

}
项目:Eclipse-Postfix-Code-Completion    文件:ColoredViewersManager.java   
public void propertyChange(PropertyChangeEvent event) {
    String property= event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR)
            || property.equals(JFacePreferences.COUNTER_COLOR)
            || property.equals(JFacePreferences.DECORATIONS_COLOR)
            || property.equals(HIGHLIGHT_BG_COLOR_NAME)
            || property.equals(HIGHLIGHT_WRITE_BG_COLOR_NAME)
            || property.equals(INHERITED_COLOR_NAME)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)
    ) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                updateAllViewers();
            }
        });
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PreferenceConstants.java   
/**
 * Initializes deprecated color constants.
 * 
 * @param store the preference store
 * @since 3.6
 */
private static void initializeDeprecatedColorConstants(IPreferenceStore store) {
    RGB bgRGB= null;
    RGB fgRGB= null;

    // Don't fail in headless mode
    if (PlatformUI.isWorkbenchRunning()) {
        bgRGB= JFaceResources.getColorRegistry().getRGB(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
        fgRGB= JFaceResources.getColorRegistry().getRGB(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
    }

    // Workaround for https://bugs.eclipse.org/306736
    if (bgRGB == null)
        bgRGB= new RGB(255, 255, 255);
    if (fgRGB == null)
        fgRGB= new RGB(0, 0, 0);

    setRGBValue(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, bgRGB);
    setRGBValue(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, fgRGB);

}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ColoredViewersManager.java   
public void propertyChange(PropertyChangeEvent event) {
    String property= event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR)
            || property.equals(JFacePreferences.COUNTER_COLOR)
            || property.equals(JFacePreferences.DECORATIONS_COLOR)
            || property.equals(HIGHLIGHT_BG_COLOR_NAME)
            || property.equals(HIGHLIGHT_WRITE_BG_COLOR_NAME)
            || property.equals(INHERITED_COLOR_NAME)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)
    ) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                updateAllViewers();
            }
        });
    }
}
项目:Pydev    文件:HierarchyLabelProvider.java   
@Override
public StyledString getStyledText(Object element) {
    if (element instanceof DataAndImageTreeNode) {
        @SuppressWarnings("rawtypes")
        DataAndImageTreeNode treeNode = (DataAndImageTreeNode) element;
        Object data = treeNode.data;
        if (data instanceof HierarchyNodeModel) {
            HierarchyNodeModel model = (HierarchyNodeModel) data;
            String spaces = "     ";
            StyledString styledString = new StyledString(model.name + spaces);
            if (model.moduleName != null && model.moduleName.trim().length() > 0) {
                Styler styler = StyledString.createColorRegistryStyler(JFacePreferences.DECORATIONS_COLOR, null);
                styledString.append("(" + model.moduleName + ")", styler);
            }
            return styledString;
        }
        return new StyledString(data.toString());
    }
    return new StyledString(element == null ? "" : element.toString());
}
项目:javapasswordsafe    文件:PasswordSafeJFace.java   
/**
 * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
 */
@Override
protected Control createContents(final Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FillLayout(SWT.VERTICAL));

    composite = new Composite(container, SWT.NONE);
    composite.setLayout(new FillLayout(SWT.VERTICAL));
    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    if (thePrefs.getBoolean(DISPLAY_AS_LIST_PREF)) {
        addTableView(composite);
        viewAsListAction.setChecked(true);
        viewAsTreeAction.setChecked(false);
    } else {
        addTreeView(composite);
        viewAsTreeAction.setChecked(true);
        viewAsListAction.setChecked(false);
    }

    final SysTray tray = new SysTray();
    final boolean isAvailable = tray.init(null);
    if (isAvailable) {
        systemTray = tray;
    }

    return container;
}
项目:javapasswordsafe    文件:PasswordSafeJFace.java   
public void setupStatusMessage() {

        final PwsFile pwsf = getPwsFile();
        if (pwsf != null && pwsf.getRecordCount() > 0) {
            final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
            if (thePrefs.getBoolean(JpwPreferenceConstants.DOUBLE_CLICK_COPIES_TO_CLIPBOARD)) {
                setStatus(Messages.getString("PasswordSafeJFace.Status.DoubleClickToCopy")); //$NON-NLS-1$
            } else {
                setStatus(Messages.getString("PasswordSafeJFace.Status.DoubleClickToEdit")); //$NON-NLS-1$
            }
        } else {
            setStatus("http://jpwsafe.sf.net"); //$NON-NLS-1$
        }

    }
项目:javapasswordsafe    文件:PasswordSafeJFace.java   
/**
 * If the user has set "Save on Update or Edit", we save the file
 * immediately.
 * 
 */
private void saveOnUpdateOrEditCheck() {
    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    if (thePrefs.getBoolean(JpwPreferenceConstants.SAVE_IMMEDIATELY_ON_EDIT)) {
        if (log.isDebugEnabled())
            log.debug("Save on Edit option active. Saving database."); //$NON-NLS-1$
        saveFileAction.run();
    }
}
项目:javapasswordsafe    文件:PasswordSafeJFace.java   
/**
 * Perform necessary shutdown operations, regardless of how the user exited
 * the application.
 * 
 */
private void tidyUpOnExit() {
    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();

    if (thePrefs.getBoolean(JpwPreferenceConstants.CLEAR_CLIPBOARD_ON_MIN)) {
        clearClipboardAction.run();
    }
    thePrefs.setValue(DISPLAY_AS_LIST_PREF, !isTreeViewShowing());
    try {
        UserPreferences.getInstance().savePreferences();
    } catch (final IOException e) {
        displayErrorDialog(
                Messages.getString("PasswordSafeJFace.SavePrefsError.Title"), Messages.getString("PasswordSafeJFace.SavePrefsError.Message") + e.getMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$
    }
}
项目:javapasswordsafe    文件:PasswordSafeJFace.java   
protected void addTableView(final Composite aComposite) {
    tableViewer = new TableViewer(aComposite, SWT.FULL_SELECTION | SWT.BORDER);
    tableViewer.addDoubleClickListener(new ViewerDoubleClickListener());
    table = tableViewer.getTable();
    table.setHeaderVisible(true);
    table.setMenu(createPopupMenu(table));
    tableViewer.setContentProvider(new PasswordTableContentProvider());
    tableViewer.setLabelProvider(new PasswordTableLabelProvider());
    tableViewer.setInput(new Object());
    tableViewer.setSorter(new PasswordTableSorter());

    viewer = tableViewer;

    int column = 1;
    addTableColumn(column, "PasswordSafeJFace.Column.Title", "table/title"); //$NON-NLS-1$

    column++;
    addTableColumn(column, "PasswordSafeJFace.Column.UserName", "table/userName"); //$NON-NLS-1$

    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    if (thePrefs.getBoolean(JpwPreferenceConstants.SHOW_NOTES_IN_LIST)) {
        column++;
        addTableColumn(column, "PasswordSafeJFace.Column.Notes", "table/notes"); //$NON-NLS-1$
    }

    column++;
    addTableColumn(column, "PasswordSafeJFace.Column.LastChanged", "table/lastChange"); //$NON-NLS-1$

    // Sort on first column
    final PasswordTableSorter pts = (PasswordTableSorter) tableViewer.getSorter();
    pts.sortOnColumn(1);

}
项目:javapasswordsafe    文件:PasswordTableSorter.java   
@Override
public int compare(final Viewer arg0, final Object a, final Object b) {

    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    final boolean showNotes = thePrefs.getBoolean(JpwPreferenceConstants.SHOW_NOTES_IN_LIST);

    int rc = 0;

    final PwsEntryBean entry1 = (PwsEntryBean) a;
    final PwsEntryBean entry2 = (PwsEntryBean) b;

    switch (column) {

    case 1:
        rc = getComparator().compare(entry1.getTitle(), entry2.getTitle());
        break;
    case 2:
        rc = getComparator().compare(entry1.getUsername(), entry2.getUsername());
        break;

    case 3:
        if (showNotes) {
            rc = getComparator().compare(entry1.getNotes(), entry2.getNotes());
        } else {
            rc = getComparator().compare(safeFormatDate(entry1.getLastChange()), safeFormatDate(entry2.getLastChange()));
        }
        break;
    case 4:
        rc = getComparator().compare(safeFormatDate(entry1.getLastChange()), safeFormatDate(entry2.getLastChange()));
        break;
    }

    if (direction == DESCENDING)
        rc = -rc;

    return rc;
}
项目:javapasswordsafe    文件:EditRecordAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    final PasswordSafeJFace app = PasswordSafeJFace.getApp();
    final PwsEntryBean selectedRecord = app.getSelectedRecord();
    if (selectedRecord != null) {
        final PwsEntryBean filledEntry = app.getPwsDataStore().getEntry(
                selectedRecord.getStoreIndex());
        EditDialog dialogue = new EditDialog(app.getShell(), filledEntry);
        app.getLockStatus().addObserver(dialogue);
        final PwsEntryBean changedEntry;
        try {
            changedEntry = (PwsEntryBean) dialogue.open();
        } finally {
            app.getLockStatus().deleteObserver(dialogue);
        }
        if (!app.isReadOnly()) {
            final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
            final boolean recordAccessTime = thePrefs
                    .getBoolean(JpwPreferenceConstants.RECORD_LAST_ACCESS_TIME);
            if (changedEntry != null) {
                if (recordAccessTime) {
                    changedEntry.setLastAccess(new Date());
                }
                app.updateRecord(changedEntry);
            } else if (recordAccessTime) { // we still have to update the
                                            // record
                filledEntry.setLastAccess(new Date());
                app.updateAccessTime(filledEntry);
            }
        }
    }

}
项目:javapasswordsafe    文件:CopyURLAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    // TODO: disable option if v1 or v2; URL only seems to be available in
    // V3 files
    final PasswordSafeJFace app = PasswordSafeJFace.getApp();

    final PwsEntryBean selected = app.getSelectedRecord();
    if (selected == null)
        return;

    // TODO: only fetch a filled entry if URL is not part of sparse fields.
    PwsEntryBean theEntry;
    if (selected.getUrl() != null && selected.getUrl().length() > 0) {
        theEntry = selected;
    } else {// retrieve filled Entry for sparse
        theEntry = app.getPwsDataStore().getEntry(selected.getStoreIndex());
    }

    Clipboard cb = new Clipboard(app.getShell().getDisplay());

    app.copyToClipboard(cb, theEntry.getUrl());

    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    final boolean recordAccessTime = thePrefs
            .getBoolean(JpwPreferenceConstants.RECORD_LAST_ACCESS_TIME);
    if (recordAccessTime) { // this could/should be sent to a background
                            // thread
        app.updateAccessTime(theEntry);
    }

    cb.dispose();
}
项目:javapasswordsafe    文件:CopyUsernameAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    PasswordSafeJFace app = PasswordSafeJFace.getApp();

    PwsEntryBean selected = app.getSelectedRecord();
    if (selected == null)
        return;

    // TODO: only fetch a filled entry if username is not part of sparse
    // fields (-> never).
    PwsEntryBean theEntry;
    if (selected.getUsername() != null && selected.getUsername().length() > 0) {
        theEntry = selected;
    } else {// retrieve filled Entry for sparse
        theEntry = app.getPwsDataStore().getEntry(selected.getStoreIndex());
    }

    Clipboard cb = new Clipboard(app.getShell().getDisplay());

    app.copyToClipboard(cb, theEntry.getUsername());

    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    final boolean recordAccessTime = thePrefs
            .getBoolean(JpwPreferenceConstants.RECORD_LAST_ACCESS_TIME);
    if (recordAccessTime) { // this could/should be sent to a background
                            // thread
        app.updateAccessTime(theEntry);
    }

    cb.dispose();
}
项目:typescript.java    文件:DecoratingTypeScriptSearchLabelProvider.java   
public void propertyChange(PropertyChangeEvent event) {
    String property= event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR) || property.equals(JFacePreferences.DECORATIONS_COLOR)
            || property.equals(HIGHLIGHT_BG_COLOR_NAME) || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                refresh();
            }
        });
    }
}
项目:hssd    文件:LPHelper.java   
@Override
public void applyStyles(TextStyle textStyle) {
    textStyle.font = getItalicFont();
    textStyle.foreground = getColor(JFacePreferences.DECORATIONS_COLOR);
    if (textStyle instanceof StyleRange) {
        ((StyleRange) textStyle).fontStyle = SWT.ITALIC;
    }
}
项目:eclipse-extras    文件:PreviewLabelProvider.java   
@Override
public Color getForeground( Object element ) {
  IProject project = ( IProject )element;
  Color result = null;
  if( !projectPatternMatcher.matches( project ) ) {
    result = JFaceResources.getColorRegistry().get( JFacePreferences.QUALIFIER_COLOR );
  }
  return result;
}
项目:APICloud-Studio    文件:InvasiveThemeHijacker.java   
protected void setHyperlinkValues(Theme theme, IEclipsePreferences prefs, boolean revertToDefaults)
{
    if (prefs == null || theme == null)
    {
        return;
    }
    if (revertToDefaults)
    {
        // Console preferences
        prefs.remove(JFacePreferences.HYPERLINK_COLOR);
        prefs.remove(JFacePreferences.ACTIVE_HYPERLINK_COLOR);

        // Editor preferences
        prefs.remove(DefaultHyperlinkPresenter.HYPERLINK_COLOR_SYSTEM_DEFAULT);
        prefs.remove(DefaultHyperlinkPresenter.HYPERLINK_COLOR);

    }
    else
    {
        TextAttribute editorHyperlink = theme.getTextAttribute("hyperlink"); //$NON-NLS-1$

        prefs.put(JFacePreferences.HYPERLINK_COLOR,
                StringConverter.asString(editorHyperlink.getForeground().getRGB()));
        JFaceResources.getColorRegistry().put(JFacePreferences.HYPERLINK_COLOR,
                editorHyperlink.getForeground().getRGB());
        prefs.put(JFacePreferences.ACTIVE_HYPERLINK_COLOR,
                StringConverter.asString(editorHyperlink.getForeground().getRGB()));
        JFaceResources.getColorRegistry().put(JFacePreferences.ACTIVE_HYPERLINK_COLOR,
                editorHyperlink.getForeground().getRGB());
        prefs.putBoolean(DefaultHyperlinkPresenter.HYPERLINK_COLOR_SYSTEM_DEFAULT, false);
        prefs.put(DefaultHyperlinkPresenter.HYPERLINK_COLOR,
                StringConverter.asString(editorHyperlink.getForeground().getRGB()));

    }

}
项目:Eclipse-Postfix-Code-Completion    文件:HierarchyLabelProvider.java   
@Override
public Color getForeground(Object element) {
    if (element instanceof IMethod) {
        if (fSpecialColor == null) {
            fSpecialColor= Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
        }
        return fSpecialColor;
    } else if (element instanceof IType && isInDifferentHierarchyScope((IType) element)) {
        return JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
    }
    return null;
}
项目:mat-calcite-plugin    文件:CalcitePane.java   
public String highlightError(Throwable e) {
    Throwable t;
    SqlParserPos errPos = null;
    for(t = e; t!=null; t = t.getCause()) {
        if (t instanceof CalciteContextException) {
            CalciteContextException cce = (CalciteContextException) t;
            errPos = new SqlParserPos(cce.getPosLine(), cce.getPosColumn(),
                    cce.getEndPosLine(), cce.getEndPosColumn());
            break;
        }
        if (t instanceof SqlParseException) {
            SqlParseException spe = (SqlParseException) t;
            errPos = spe.getPos();
            break;
        }
    }
    if (errPos == null) {
        return null;
    }

    String sql = queryViewer.getDocument().get();
    StyleRange style = new StyleRange();
    int start = SqlParserUtil.lineColToIndex(sql, errPos.getLineNum(), errPos.getColumnNum());
    int end = SqlParserUtil.lineColToIndex(sql, errPos.getEndLineNum(), errPos.getEndColumnNum()) + 1;
    style.start = start;
    style.length = end - start;
    style.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR);
    style.underline = true;
    style.underlineStyle = SWT.UNDERLINE_SQUIGGLE;
    queryString.replaceStyleRanges(start, end - start, new StyleRange[] { style });
    return t.getMessage();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:HierarchyLabelProvider.java   
@Override
public Color getForeground(Object element) {
    if (element instanceof IMethod) {
        if (fSpecialColor == null) {
            fSpecialColor= Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
        }
        return fSpecialColor;
    } else if (element instanceof IType && isInDifferentHierarchyScope((IType) element)) {
        return JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
    }
    return null;
}
项目:eclipsensis    文件:NSISConsoleViewer.java   
@Override
public void lineGetStyle(LineStyleEvent event)
{
    IDocument document = getDocument();
    if (document != null && document.getLength() > 0) {
        List<StyleRange> ranges = new ArrayList<StyleRange>();
        int offset = event.lineOffset;
        int length = event.lineText.length();

        StyleRange[] partitionerStyles = ((IConsoleDocumentPartitioner) document.getDocumentPartitioner()).getStyleRanges(event.lineOffset, event.lineText.length());
        if (partitionerStyles != null) {
            for (int i = 0; i < partitionerStyles.length; i++) {
                ranges.add(partitionerStyles[i]);
            }
        }

        try {
            Position[] positions = getDocument().getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
            Position[] overlap = findPosition(offset, length, positions);
            if (overlap != null) {
                Color color = JFaceResources.getColorRegistry().get(JFacePreferences.HYPERLINK_COLOR);
                for (int i = 0; i < overlap.length; i++) {
                    Position position = overlap[i];
                    StyleRange linkRange = new StyleRange(position.offset, position.length, color, null);
                    linkRange.underline = true;
                    override(ranges, linkRange);
                }
            }
        } catch (BadPositionCategoryException e) {
        }

        if (ranges.size() > 0) {
            event.styles = ranges.toArray(new StyleRange[ranges.size()]);
        }
    }
}
项目:Pydev    文件:DecoratingFileSearchLabelProvider.java   
@Override
public void propertyChange(PropertyChangeEvent event) {
    String property = event.getProperty();
    if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR)
            || property.equals(JFacePreferences.DECORATIONS_COLOR)
            || property.equals(HIGHLIGHT_BG_COLOR_NAME)
            || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS)) {
        Display.getDefault().asyncExec(new Runnable() {
            @Override
            public void run() {
                refresh();
            }
        });
    }
}
项目:javapasswordsafe    文件:PasswordSafeJFace.java   
protected void addTreeView(final Composite aComposite) {
    treeViewer = new TreeViewer(aComposite, SWT.BORDER);
    treeViewer.setLabelProvider(new PasswordTreeLabelProvider());
    treeViewer.setContentProvider(new PasswordTreeContentProvider());
    treeViewer.setSorter(new ViewerSorter());
    treeViewer.addDoubleClickListener(new ViewerDoubleClickListener());
    final int operations = DND.DROP_COPY| DND.DROP_MOVE;
    final Transfer[] transferTypes = new Transfer[]
            {PwsEntryBeanTransfer.getInstance(), TextTransfer.getInstance()};
    treeViewer.addDragSupport(operations, transferTypes , new TreeDragListener(treeViewer));
    treeViewer.addDropSupport(operations, transferTypes, new TreeDropper(treeViewer));
    treeViewer.setComparer(new IElementComparer() {
        public boolean equals(final Object a, final Object b) {
            if (a instanceof PwsEntryBean && b instanceof PwsEntryBean)
                return ((PwsEntryBean) a).getStoreIndex() == (((PwsEntryBean) b)
                        .getStoreIndex());
            else
                return a.equals(b);
        }

        public int hashCode(final Object element) {
            if (element instanceof PwsEntryBean)
                return ((PwsEntryBean) element).getStoreIndex();
            else
                return element.hashCode();
        }
    });
    tree = treeViewer.getTree();
    tree.setHeaderVisible(true);
    tree.setMenu(createPopupMenu(tree));

    treeViewer.setInput(new Object());
    viewer = treeViewer;

    int column = 1;
    addTreeColumn(column, "PasswordSafeJFace.Column.Title", "tree/title");//$NON-NLS-1$

    column++;
    addTreeColumn(column, "PasswordSafeJFace.Column.UserName", "tree/userName");//$NON-NLS-1$

    final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
    if (thePrefs.getBoolean(JpwPreferenceConstants.SHOW_NOTES_IN_LIST)) {
        column++;
        addTreeColumn(column, "PasswordSafeJFace.Column.Notes", "tree/notes");//$NON-NLS-1$
    }

    final TreeColumn[] columns = tree.getColumns();
    for (int i = 0; i < columns.length; i++) {
        // ps.getDefaultInt("bla");
        // columns[i].setWidth(100);
        columns[i].setMoveable(true);
    }
    // treeViewer.setExpandedState(arg0, arg1)

}
项目:javapasswordsafe    文件:JpwPreferenceInitializer.java   
@Override
public void initializeDefaultPreferences() {
    // Use a scope etc. once we migrate to Eclipse RCP.
    // IScopeContext theContext = new DefaultScope();

    // For now we simply use:
    final IPreferenceStore theStore = JFacePreferences.getPreferenceStore();

    // Display
    theStore.setDefault(ALWAYS_ON_TOP, false);
    theStore.setDefault(SHOW_NOTES_IN_LIST, true);
    theStore.setDefault(SHOW_NOTES_IN_EDIT_MODE, true);
    theStore.setDefault(SHOW_PASSWORD_IN_EDIT_MODE, false);
    theStore.setDefault(SHOW_ICON_IN_SYSTEM_TRAY, false);
    theStore.setDefault(TREE_COLUMN_SIZE, 150);
    theStore.setDefault(TABLE_COLUMN_SIZE, 150);

    // Password Policy
    theStore.setDefault(DEFAULT_PASSWORD_LENGTH, 8);
    theStore.setDefault(USE_LOWERCASE_LETTERS, true);
    theStore.setDefault(USE_UPPERCASE_LETTERS, true);
    theStore.setDefault(USE_DIGITS, true);
    theStore.setDefault(USE_SYMBOLS, false);
    theStore.setDefault(USE_EASY_TO_READ, false);
    theStore.setDefault(USE_HEX_ONLY, false);

    // User name
    theStore.setDefault(USE_DEFAULT_USERNAME, false);
    theStore.setDefault(DEFAULT_USERNAME, "");
    theStore.setDefault(QUERY_FOR_DEFAULT_USERNAME, false);

    // Security
    theStore.setDefault(CLEAR_CLIPBOARD_ON_MIN, false);
    theStore.setDefault(LOCK_DB_ON_MIN, false);
    theStore.setDefault(CONFIRM_SAVE_ON_MIN, false);
    theStore.setDefault(CONFIRM_COPY_TO_CLIPBOARD, false);
    theStore.setDefault(LOCK_DB_ON_WS_LOCK, true);
    theStore.setDefault(LOCK_ON_IDLE, true);
    theStore.setDefault(LOCK_ON_IDLE_MINS, 5);
    theStore.setDefault(CONFIRM_SAVE_ON_MIN, false);

    // Misc
    theStore.setDefault(CONFIRM_ITEM_DELETION, true);
    theStore.setDefault(SAVE_IMMEDIATELY_ON_EDIT, true);
    theStore.setDefault(ESCAPE_KEY_EXITS_APP, false);
    theStore.setDefault(HOT_KEY_ACTIVE, false);
    theStore.setDefault(HOT_KEY, false);
    theStore.setDefault(DOUBLE_CLICK_COPIES_TO_CLIPBOARD, true);
    theStore.setDefault(DEFAULT_OPEN_READ_ONLY, false);
    theStore.setDefault(RECORD_LAST_ACCESS_TIME, false);

}
项目:javapasswordsafe    文件:OptionsAction.java   
/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    final PasswordSafeJFace app = PasswordSafeJFace.getApp();

    // Create the preference manager
    PreferenceManager mgr = new PreferenceManager();

    // Create the nodes
    PreferenceNode displayPrefs = new PreferenceNode(
            "display", Messages.getString("OptionsAction.DisplayNode"), null, DisplayPreferences.class.getName()); //$NON-NLS-1$ //$NON-NLS-2$
    PreferenceNode securityPrefs = new PreferenceNode(
            "security", Messages.getString("OptionsAction.SecurityNode"), null, SecurityPreferences.class //$NON-NLS-1$ //$NON-NLS-2$
                    .getName());
    PreferenceNode passwordPolicyPrefs = new PreferenceNode(
            "policy", Messages.getString("OptionsAction.PolicyNode"), null, //$NON-NLS-1$ //$NON-NLS-2$
            PasswordPolicyPreferences.class.getName());
    PreferenceNode usernamePrefs = new PreferenceNode(
            "username", Messages.getString("OptionsAction.UserNameNode"), null, UsernamePreferences.class //$NON-NLS-1$ //$NON-NLS-2$
                    .getName());
    PreferenceNode miscPrefs = new PreferenceNode(
            "misc", Messages.getString("OptionsAction.MiscNode"), null, MiscPreferences.class.getName()); //$NON-NLS-1$ //$NON-NLS-2$

    // Add the nodes
    mgr.addToRoot(displayPrefs);
    mgr.addToRoot(securityPrefs);
    mgr.addToRoot(passwordPolicyPrefs);
    mgr.addToRoot(usernamePrefs);
    mgr.addToRoot(miscPrefs);

    // Create the preferences dialog
    PreferenceDialog dlg = new PreferenceDialog(app.getShell(), mgr);
    Window.setDefaultImage(IOUtils.getImage(PasswordSafeJFace.class,
            "/org/pwsafe/passwordsafeswt/images/clogo.gif")); //$NON-NLS-1$

    // Set the preference store
    dlg.setPreferenceStore(JFacePreferences.getPreferenceStore());

    // Open the dialog
    dlg.open();

    try {
        if (JFacePreferences.getPreferenceStore().needsSaving()) {
            // Be Paranoid - Save the preferences now
            UserPreferences.getInstance().savePreferences();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}
项目:TranskribusSwtGui    文件:MyContentProposalAdapter.java   
@Override
protected Color getForeground() {
    return JFaceResources.getColorRegistry().get(
            JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
}
项目:TranskribusSwtGui    文件:MyContentProposalAdapter.java   
@Override
protected Color getBackground() {
    return JFaceResources.getColorRegistry().get(
            JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
}
项目:gef-gwt    文件:ContentProposalAdapter.java   
protected Color getForeground() {
    return JFaceResources.getColorRegistry().get(
            JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
}
项目:gef-gwt    文件:ContentProposalAdapter.java   
protected Color getBackground() {
    return JFaceResources.getColorRegistry().get(
            JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
}
项目:gef-gwt    文件:JFaceColors.java   
/**
 * @param display the display the color is from
 * @return the default color to use for displaying errors.
 * @see ColorRegistry#get(String)
 * @see JFacePreferences#ERROR_COLOR
 */
public static Color getErrorText(Display display) {
    return JFaceResources.getColorRegistry().get(
            JFacePreferences.ERROR_COLOR);
}
项目:gef-gwt    文件:JFaceColors.java   
/**
 * @param display the display the color is from
 * @return the default color to use for displaying hyperlinks.
 * @see ColorRegistry#get(String)
 * @see JFacePreferences#HYPERLINK_COLOR
 */
public static Color getHyperlinkText(Display display) {
    return JFaceResources.getColorRegistry().get(
            JFacePreferences.HYPERLINK_COLOR);
}
项目:gef-gwt    文件:JFaceColors.java   
/**
 * @param display the display the color is from
 * @return the default color to use for displaying active hyperlinks.
 * @see ColorRegistry#get(String)
 * @see JFacePreferences#ACTIVE_HYPERLINK_COLOR
 */
public static Color getActiveHyperlinkText(Display display) {
    return JFaceResources.getColorRegistry().get(
            JFacePreferences.ACTIVE_HYPERLINK_COLOR);
}