diff options
Diffstat (limited to 'bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ToggleViewLayoutAction.java')
-rw-r--r-- | bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ToggleViewLayoutAction.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ToggleViewLayoutAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ToggleViewLayoutAction.java new file mode 100644 index 000000000..e7a13b425 --- /dev/null +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ToggleViewLayoutAction.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.internal.ui.synchronize.actions; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.SWT; +import org.eclipse.team.internal.ui.Utils; +import org.eclipse.team.ui.synchronize.TeamSubscriberParticipant; + +public class ToggleViewLayoutAction extends Action implements IPropertyChangeListener { + private int layout; + private TeamSubscriberParticipant participant; + + public ToggleViewLayoutAction(TeamSubscriberParticipant participant, int layout) { + super(null, SWT.RADIO); + this.participant = participant; + this.layout = layout; + if(layout == TeamSubscriberParticipant.TABLE_LAYOUT) { + Utils.initAction(this, "action.toggleViewFlat."); //$NON-NLS-1$ + } else { + Utils.initAction(this, "action.toggleViewHierarchical."); //$NON-NLS-1$ + } + setChecked(participant.getLayout() == layout); + participant.addPropertyChangeListener(this); + } + + public void run() { + participant.setLayout(layout); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + if(event.getProperty().equals(TeamSubscriberParticipant.P_SYNCVIEWPAGE_LAYOUT)) { + Integer newLayout = (Integer)event.getNewValue(); + setChecked(newLayout.intValue() == layout); + } + } +}
\ No newline at end of file |