use of org.eclipse.jface.util.IPropertyChangeListener in project mylyn.docs by eclipse.
the class PreferenceStoreFacade method firePropertyChangeEvent.
public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
if (listeners.isEmpty()) {
return;
}
// always get the new value again in case the get methods have been overridden
if (newValue instanceof Boolean) {
newValue = getBoolean(name);
} else if (newValue instanceof Integer) {
newValue = getInt(name);
} else if (newValue instanceof Long) {
newValue = getLong(name);
} else if (newValue instanceof Double) {
newValue = getDouble(name);
} else if (newValue instanceof Float) {
newValue = getFloat(name);
} else if (newValue instanceof String) {
newValue = getString(name);
}
if (newValue == oldValue || (newValue != null && newValue.equals(oldValue))) {
return;
}
PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue);
for (Object o : listeners.getListeners()) {
IPropertyChangeListener listener = (IPropertyChangeListener) o;
listener.propertyChange(event);
}
}
use of org.eclipse.jface.util.IPropertyChangeListener in project egit by eclipse.
the class GitModelSynchronizeParticipant method initializeConfiguration.
@Override
protected void initializeConfiguration(final ISynchronizePageConfiguration configuration) {
configuration.setProperty(ISynchronizePageConfiguration.P_VIEWER_ID, VIEWER_ID);
String modelProvider = WORKSPACE_MODEL_PROVIDER_ID;
final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
if (!gsds.containsFolderLevelSynchronizationRequest()) {
if (preferenceStore.getBoolean(UIPreferences.SYNC_VIEW_ALWAYS_SHOW_CHANGESET_MODEL)) {
modelProvider = GitChangeSetModelProvider.ID;
} else {
String lastSelectedModel = preferenceStore.getString(UIPreferences.SYNC_VIEW_LAST_SELECTED_MODEL);
if (// $NON-NLS-1$
!"".equals(lastSelectedModel))
modelProvider = lastSelectedModel;
}
}
configuration.setProperty(ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER, modelProvider);
configuration.setProperty(SYNCHRONIZATION_DATA, gsds);
super.initializeConfiguration(configuration);
configuration.addActionContribution(new GitActionContributor());
configuration.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
if (property.equals(ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER)) {
String newValue = (String) event.getNewValue();
preferenceStore.setValue(UIPreferences.SYNC_VIEW_LAST_SELECTED_MODEL, newValue);
} else if (property.equals(P_NAVIGATOR)) {
Object oldNavigator = configuration.getProperty(P_NAVIGATOR);
if (!(oldNavigator instanceof GitTreeCompareNavigator))
configuration.setProperty(P_NAVIGATOR, new GitTreeCompareNavigator((CompareNavigator) oldNavigator));
}
}
});
}
use of org.eclipse.jface.util.IPropertyChangeListener in project egit by eclipse.
the class CommitEditorPage method createUserArea.
private Composite createUserArea(Composite parent, FormToolkit toolkit, PersonIdent person, boolean author) {
Composite userArea = toolkit.createComposite(parent);
GridLayoutFactory.fillDefaults().spacing(2, 2).numColumns(3).applyTo(userArea);
Label userLabel = toolkit.createLabel(userArea, null);
userLabel.setImage(getImage(author ? UIIcons.ELCL16_AUTHOR : UIIcons.ELCL16_COMMITTER));
if (author)
userLabel.setToolTipText(UIText.CommitEditorPage_TooltipAuthor);
else
userLabel.setToolTipText(UIText.CommitEditorPage_TooltipCommitter);
boolean signedOff = isSignedOffBy(person);
final Text userText = new Text(userArea, SWT.FLAT | SWT.READ_ONLY);
addToFocusTracking(userText);
setPerson(userText, person, author);
toolkit.adapt(userText, false, false);
userText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
IPropertyChangeListener uiPrefsListener = (event) -> {
String property = event.getProperty();
if (UIPreferences.DATE_FORMAT.equals(property) || UIPreferences.DATE_FORMAT_CHOICE.equals(property)) {
setPerson(userText, person, author);
userArea.layout();
}
};
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(uiPrefsListener);
userText.addDisposeListener((e) -> {
Activator.getDefault().getPreferenceStore().removePropertyChangeListener(uiPrefsListener);
});
GridDataFactory.fillDefaults().span(signedOff ? 1 : 2, 1).applyTo(userText);
if (signedOff) {
Label signedOffLabel = toolkit.createLabel(userArea, null);
signedOffLabel.setImage(getImage(UIIcons.SIGNED_OFF));
if (author)
signedOffLabel.setToolTipText(UIText.CommitEditorPage_TooltipSignedOffByAuthor);
else
signedOffLabel.setToolTipText(UIText.CommitEditorPage_TooltipSignedOffByCommitter);
}
return userArea;
}
use of org.eclipse.jface.util.IPropertyChangeListener in project egit by eclipse.
the class RebaseInteractiveView method createPartControl.
@Override
public void createPartControl(Composite parent) {
GridLayoutFactory.fillDefaults().applyTo(parent);
final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
toolkit.dispose();
}
});
form = createForm(parent, toolkit);
createCommandToolBar(form, toolkit);
planTreeViewer = createPlanTreeViewer(form.getBody(), toolkit);
planLayout = new PlanLayout();
planTreeViewer.getTree().getParent().setLayout(planLayout);
createColumns(planLayout);
createStepActionToolBar(toolkit);
createPopupMenu(planTreeViewer);
setupListeners();
createLocalDragandDrop();
planTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
PlanElement element = (PlanElement) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (element == null)
return;
RepositoryCommit commit = loadCommit(element.getCommit());
if (commit != null)
CommitEditor.openQuiet(commit);
}
private RepositoryCommit loadCommit(AbbreviatedObjectId abbreviatedObjectId) {
if (abbreviatedObjectId != null) {
try (RevWalk walk = new RevWalk(RebaseInteractiveView.this.currentRepository)) {
Collection<ObjectId> resolved = walk.getObjectReader().resolve(abbreviatedObjectId);
if (resolved.size() == 1) {
RevCommit commit = walk.parseCommit(resolved.iterator().next());
return new RepositoryCommit(RebaseInteractiveView.this.currentRepository, commit);
}
} catch (IOException e) {
return null;
}
}
return null;
}
});
prefListener = new IPreferenceChangeListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (!RepositoryUtil.PREFS_DIRECTORIES_REL.equals(event.getKey())) {
return;
}
final Repository repo = currentRepository;
if (repo == null)
return;
if (Activator.getDefault().getRepositoryUtil().contains(repo))
return;
// Unselect repository as it has been removed
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
currentRepository = null;
showRepository(null);
}
});
}
};
InstanceScope.INSTANCE.getNode(org.eclipse.egit.core.Activator.getPluginId()).addPreferenceChangeListener(prefListener);
uiPrefsListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
if (UIPreferences.DATE_FORMAT.equals(property) || UIPreferences.DATE_FORMAT_CHOICE.equals(property) || UIPreferences.RESOURCEHISTORY_SHOW_RELATIVE_DATE.equals(property)) {
refresh();
}
}
};
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(uiPrefsListener);
IActionBars actionBars = getViewSite().getActionBars();
IToolBarManager toolbar = actionBars.getToolBarManager();
listenOnRepositoryViewSelection = RebaseInteractivePreferences.isReactOnSelection();
// link with selection
Action linkSelectionAction = new BooleanPrefAction((IPersistentPreferenceStore) Activator.getDefault().getPreferenceStore(), UIPreferences.REBASE_INTERACTIVE_SYNC_SELECTION, UIText.InteractiveRebaseView_LinkSelection) {
@Override
public void apply(boolean value) {
listenOnRepositoryViewSelection = value;
}
};
linkSelectionAction.setImageDescriptor(UIIcons.ELCL16_SYNCED);
toolbar.add(linkSelectionAction);
switchRepositoriesAction = new RepositoryToolbarAction(false, () -> currentRepository, repo -> setInput(new StructuredSelection(repo)));
toolbar.add(switchRepositoriesAction);
UIUtils.notifySelectionChangedWithCurrentSelection(selectionChangedListener, getSite());
getSite().setSelectionProvider(new RepositorySelectionProvider(planTreeViewer, () -> currentRepository));
}
use of org.eclipse.jface.util.IPropertyChangeListener in project egit by eclipse.
the class CommittingPreferencePage method initialize.
@Override
protected void initialize() {
super.initialize();
useStagingView.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (FieldEditor.VALUE.equals(event.getProperty())) {
autoStage.setEnabled(((Boolean) event.getNewValue()).booleanValue(), generalGroup);
}
}
});
}
Aggregations