logo       
Bookmark and Share

Re: [Subclipse-dev] [Patch] Move the 'SVN Properties View' to the eclipse : msg#00042

version-control.subversion.subclipse.devel

Subject: Re: [Subclipse-dev] [Patch] Move the 'SVN Properties View' to the eclipse property dialog

Manfred,
I have attached a patch i started a few weeks ago to add an SVN tab to the properties view. It is currently read only, but could easily be extended to support editing. Unfortunately, this only works for the Project explorer, as it is the only object to expose an extensible property sheet (tabbed property view). All of the old views just expose a tabular set of propertes that can not accept contributions (to the best of my knowledge).

cheers,
Brock

Manfred Klug wrote:
In addition to the patch the following classes are no longer needed.

org.tigris.subversion.subclipse.ui.actions.SVNPropertyAction
org.tigris.subversion.subclipse.ui.actions.SVNPropertyDeleteAction
org.tigris.subversion.subclipse.ui.actions.SVNPropertyModifyAction
org.tigris.subversion.subclipse.ui.actions.SVNPropertySaveAction

Manfred

______________________________________________________________________________
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xxxxxxxxxxxxxxxxxxxx
For additional commands, e-mail: dev-help@xxxxxxxxxxxxxxxxxxxx

Index: D:/data/eclipse/workspace/ui/META-INF/MANIFEST.MF
===================================================================
--- D:/data/eclipse/workspace/ui/META-INF/MANIFEST.MF (revision 2829)
+++ D:/data/eclipse/workspace/ui/META-INF/MANIFEST.MF (working copy)
@@ -21,7 +21,8 @@
org.eclipse.ui.console,
org.eclipse.help,
org.eclipse.jdt.ui;resolution:=optional,
- org.eclipse.jdt.core;resolution:=optional
+ org.eclipse.jdt.core;resolution:=optional,
+ org.eclipse.ui.views.properties.tabbed
Eclipse-LazyStart: true
Export-Package: org.tigris.subversion.subclipse.ui,
org.tigris.subversion.subclipse.ui.actions,
Index: D:/data/eclipse/workspace/ui/plugin.xml
===================================================================
--- D:/data/eclipse/workspace/ui/plugin.xml (revision 2830)
+++ D:/data/eclipse/workspace/ui/plugin.xml (working copy)
@@ -1203,5 +1203,31 @@
</description>
</transfer>
</extension>
-
+ <extension
+ point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
+ <propertyTabs
+ contributorId="org.eclipse.ui.navigator.ProjectExplorer">
+ <propertyTab
+ category="core"
+ id="org.tigris.subversion.subclipse.ui.svn"
+ label="SVN">
+ </propertyTab>
+ </propertyTabs>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views.properties.tabbed.propertySections">
+ <propertySections
+ contributorId="org.eclipse.ui.navigator.ProjectExplorer">
+ <propertySection
+
class="org.tigris.subversion.subclipse.ui.svnproperties.SvnPropertySection"
+ enablesFor="1"
+
filter="org.tigris.subversion.subclipse.ui.svnproperties.SvnFilter"
+ id="org.tigris.subversion.subclipse.ui.info"
+ tab="org.tigris.subversion.subclipse.ui.svn">
+ <input
+ type="org.eclipse.core.runtime.IAdaptable">
+ </input>
+ </propertySection>
+ </propertySections>
+ </extension>
</plugin>
Index:
D:/data/eclipse/workspace/ui/src/org/tigris/subversion/subclipse/ui/svnproperties/SvnFilter.java
===================================================================
---
D:/data/eclipse/workspace/ui/src/org/tigris/subversion/subclipse/ui/svnproperties/SvnFilter.java
(revision 0)
+++
D:/data/eclipse/workspace/ui/src/org/tigris/subversion/subclipse/ui/svnproperties/SvnFilter.java
(revision 0)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Subclipse project and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Subclipse project committers - initial API and implementation
+
******************************************************************************/
+package org.tigris.subversion.subclipse.ui.svnproperties;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IFilter;
+import org.tigris.subversion.subclipse.core.ISVNLocalResource;
+
+/**
+ * Used to filter out IAdaptables that do not adapt to ISVNResource. This
class
+ * is needed as there is no way to use IAdaptables in the tabbed property view
+ *
+ * @author Brock Janiczak
+ */
+public class SvnFilter implements IFilter {
+
+ public boolean select(Object toTest) {
+ IAdaptable adaptable = (IAdaptable) toTest;
+ if (adaptable.getAdapter(ISVNLocalResource.class) != null) {
+ return true;
+ }
+
+ IResource resource = (IResource)
adaptable.getAdapter(IResource.class);
+ return resource != null &&
resource.getAdapter(ISVNLocalResource.class) != null;
+ }
+
+}
Index:
D:/data/eclipse/workspace/ui/src/org/tigris/subversion/subclipse/ui/svnproperties/SvnPropertySection.java
===================================================================
---
D:/data/eclipse/workspace/ui/src/org/tigris/subversion/subclipse/ui/svnproperties/SvnPropertySection.java
(revision 0)
+++
D:/data/eclipse/workspace/ui/src/org/tigris/subversion/subclipse/ui/svnproperties/SvnPropertySection.java
(revision 0)
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Subclipse project and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Subclipse project committers - initial API and implementation
+
******************************************************************************/
+package org.tigris.subversion.subclipse.ui.svnproperties;
+
+import java.text.DateFormat;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.IExpansionListener;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+import org.tigris.subversion.subclipse.core.IResourceStateChangeListener;
+import org.tigris.subversion.subclipse.core.ISVNLocalResource;
+import org.tigris.subversion.subclipse.core.SVNException;
+import org.tigris.subversion.subclipse.core.SVNProviderPlugin;
+import org.tigris.subversion.subclipse.core.resources.LocalResourceStatus;
+import org.tigris.subversion.svnclientadapter.ISVNProperty;
+
+public class SvnPropertySection extends AbstractPropertySection {
+ private static final DateFormat dateTimeFormat =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
+ private static final int WIDTH = 100;
+ private static final int LABEL_WIDTH = 75;
+
+ private IResource selectedIResource;
+ private ISVNLocalResource selectedResource;
+ private Label revision;
+ private Label textStatus;
+ private Label propStatus;
+ private Label lockDate;
+ private Label lockOwner;
+ private Label lockComment;
+ private ExpandableComposite propertySection;
+ private Composite parent;
+ private Label url;
+
+ private GridDataFactory labelGDFactory =
GridDataFactory.swtDefaults().hint(LABEL_WIDTH, SWT.DEFAULT);
+ private GridDataFactory contentGDFactory =
GridDataFactory.swtDefaults().hint(WIDTH, SWT.DEFAULT);
+
+
+ private IResourceStateChangeListener resourceStateChangeListener = new
IResourceStateChangeListener() {
+
+ public void projectConfigured(IProject project) {
+ if (selectedIResource != null) {
+ if (project.contains(selectedIResource)) {
+ Display.getDefault().syncExec(new
Runnable() {
+
+ public void run() {
+ refresh();
+ }
+
+ });
+ }
+ }
+ }
+
+ public void projectDeconfigured(IProject project) {
+ if (selectedIResource != null) {
+ if (project.contains(selectedIResource)) {
+ Display.getDefault().syncExec(new
Runnable() {
+
+ public void run() {
+ refresh();
+ }
+
+ });
+ }
+ }
+ }
+
+ public void resourceModified(IResource[] changedResources) {
+ if (selectedIResource != null) {
+ for (int i = 0; i < changedResources.length;
i++) {
+ if
(changedResources[i].equals(selectedIResource)) {
+
Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ refresh();
+ }
+
+ });
+ }
+ }
+ }
+ }
+
+ public void resourceSyncInfoChanged(IResource[]
changedResources) {
+ if (selectedIResource != null) {
+ for (int i = 0; i < changedResources.length;
i++) {
+ if
(changedResources[i].equals(selectedIResource)) {
+
Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ refresh();
+ }
+
+ });
+ }
+ }
+ }
+ }
+
+ };
+
+ public SvnPropertySection() {
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite,
org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
+ */
+ public void createControls(final Composite parent,
TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ this.parent = parent;
+ GridLayout parentLayout = new GridLayout(1, false);
+ parentLayout.marginHeight = 0;
+ parentLayout.marginWidth = 0;
+ parent.setLayout(parentLayout);
+
+ super.createControls(parent, aTabbedPropertySheetPage);
+
+
+ TabbedPropertySheetWidgetFactory widgetFactory =
getWidgetFactory();
+ ExpandableComposite infoSection =
widgetFactory.createExpandableComposite(parent, ExpandableComposite.TWISTIE |
ExpandableComposite.EXPANDED | ExpandableComposite.SHORT_TITLE_BAR);
+
infoSection.setLayoutData(GridDataFactory.fillDefaults().grab(true,
true).create());
+ infoSection.setText("SVN Information");
+ infoSection.addExpansionListener(new IExpansionListener() {
+
+ public void expansionStateChanging(ExpansionEvent e) {
+ }
+
+ public void expansionStateChanged(ExpansionEvent e) {
+ parent.setSize(parent.computeSize(SWT.DEFAULT,
SWT.DEFAULT));
+ parent.layout(true);
+ }
+
+ });
+ Composite c = widgetFactory.createComposite(infoSection);
+ GridLayout gridLayout = new GridLayout(4, false);
+ gridLayout.marginHeight = 0;
+ c.setLayout(gridLayout);
+
+ widgetFactory.createLabel(c,
"URL").setLayoutData(labelGDFactory.create());
+ url = widgetFactory.createLabel(c, "");
+ url.setLayoutData(GridDataFactory.fillDefaults().span(3,
1).create());
+
+ widgetFactory.createLabel(c,
"Revision").setLayoutData(labelGDFactory.create());
+ revision = widgetFactory.createLabel(c, "");
+ revision.setLayoutData(contentGDFactory.create());
+
+ widgetFactory.createLabel(c, "").setLayoutData(new
GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
+
+ widgetFactory.createLabel(c, "Text
Status").setLayoutData(labelGDFactory.create());
+ textStatus = widgetFactory.createLabel(c, "");
+ textStatus.setLayoutData(contentGDFactory.create());
+
+ widgetFactory.createLabel(c, "Prop
Status").setLayoutData(labelGDFactory.create());
+ propStatus = widgetFactory.createLabel(c, "");
+ propStatus.setLayoutData(contentGDFactory.create());
+
+ widgetFactory.createLabel(c, "Locked
By").setLayoutData(labelGDFactory.create());
+ lockOwner = widgetFactory.createLabel(c, "");
+ lockOwner.setLayoutData(contentGDFactory.create());
+
+ widgetFactory.createLabel(c, "Lock
Date").setLayoutData(labelGDFactory.create());
+ lockDate = widgetFactory.createLabel(c, "");
+ lockDate.setLayoutData(contentGDFactory.create());
+
+ widgetFactory.createLabel(c, "Lock
Comment").setLayoutData(labelGDFactory.create());
+ lockComment = widgetFactory.createLabel(c, "");
+
lockComment.setLayoutData(GridDataFactory.fillDefaults().hint(WIDTH,
SWT.DEFAULT).span(3, 1).create());
+
+ infoSection.setClient(c);
+
+ propertySection =
widgetFactory.createExpandableComposite(parent, ExpandableComposite.TWISTIE |
ExpandableComposite.SHORT_TITLE_BAR);
+ propertySection.setText("Properties");
+ propertySection.addExpansionListener(new IExpansionListener() {
+
+ public void expansionStateChanging(ExpansionEvent e) {
+
+ }
+
+ public void expansionStateChanged(ExpansionEvent e) {
+ parent.setSize(parent.computeSize(SWT.DEFAULT,
SWT.DEFAULT));
+ parent.layout(true);
+ }
+
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart,
org.eclipse.jface.viewers.ISelection)
+ */
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ IAdaptable adaptable =
(IAdaptable)((IStructuredSelection)selection).getFirstElement();
+ selectedIResource = (IResource)
adaptable.getAdapter(IResource.class);
+ if (selectedIResource != null) {
+ selectedResource = (ISVNLocalResource)
selectedIResource.getAdapter(ISVNLocalResource.class);
+ } else {
+ selectedResource = null;
+ }
+ refresh();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#aboutToBeShown()
+ */
+ public void aboutToBeShown() {
+ refresh();
+
SVNProviderPlugin.addResourceStateChangeListener(resourceStateChangeListener);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#aboutToBeHidden()
+ */
+ public void aboutToBeHidden() {
+
SVNProviderPlugin.removeResourceStateChangeListener(resourceStateChangeListener);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ public void refresh() {
+ if (selectedResource == null) {
+ return;
+ }
+
+ try {
+ LocalResourceStatus status =
selectedResource.getStatus();
+ if (status.getUrlString() != null) {
+ url.setText(status.getUrlString());
+ } else {
+ url.setText("");
+ }
+
+ if (status.getLastChangedRevision() != null) {
+
revision.setText(status.getLastChangedRevision().toString());
+ } else {
+ revision.setText("");
+ }
+ textStatus.setText(status.getTextStatus().toString());
+ propStatus.setText(status.getPropStatus().toString());
+ if (status.getLockCreationDate() != null) {
+
lockDate.setText(dateTimeFormat.format(status.getLockCreationDate()));
+ } else {
+ lockDate.setText("");
+ }
+ if (status.getLockOwner() != null) {
+ lockOwner.setText(status.getLockOwner());
+ lockComment.setText(status.getLockComment());
+ } else {
+ lockOwner.setText("");
+ lockComment.setText("");
+ }
+ } catch (SVNException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (propertySection.getClient() != null) {
+ propertySection.getClient().dispose();
+ }
+
+ try {
+ TabbedPropertySheetWidgetFactory widgetFactory =
getWidgetFactory();
+ Composite propComposite =
widgetFactory.createComposite(propertySection);
+ propComposite.setLayout(new GridLayout(2, false));
+ if (selectedResource != null &&
selectedResource.getRepository() != null) {
+ ISVNProperty[] svnProperties =
selectedResource.getSvnProperties();
+ for (int i = 0; i < svnProperties.length; i++) {
+ ISVNProperty property =
svnProperties[i];
+
widgetFactory.createLabel(propComposite,
property.getName()).setLayoutData(labelGDFactory.create());
+
widgetFactory.createLabel(propComposite,
property.getValue()).setLayoutData(contentGDFactory.create());
+ }
+ }
+ propertySection.setClient(propComposite);
+ propertySection.layout(true);
+ parent.setSize(parent.computeSize(SWT.DEFAULT,
SWT.DEFAULT));
+ parent.layout(true);
+ } catch (SVNException e) {
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#shouldUseExtraSpace()
+ */
+ public boolean shouldUseExtraSpace() {
+ // TODO Auto-generated method stub
+ return super.shouldUseExtraSpace();
+ }
+
+}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xxxxxxxxxxxxxxxxxxxx
For additional commands, e-mail: dev-help@xxxxxxxxxxxxxxxxxxxx
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise