--- /dev/null
+/*
+ * Copyright (c) 2003-2004 Christopher Lenz 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:
+ * Christopher Lenz - initial API and implementation
+ *
+ * $Id: CssOutlineDoubleClickListener.java,v 1.1 2004-09-02 18:11:49 jsurfer Exp $
+ */
+
+package net.sourceforge.phpeclipse.css.ui.internal.outline;
+
+import net.sourceforge.phpeclipse.css.core.model.IStyleRule;
+import net.sourceforge.phpeclipse.css.ui.CssUI;
+
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+
+/**
+ * A double click listener that is intended to be attached to an outline page
+ * displaying CSS elements. If a style rule is double clicked, it will attempt
+ * to show the standard properties view.
+ */
+public class CssOutlineDoubleClickListener implements IDoubleClickListener {
+
+ // Instance Variables ------------------------------------------------------
+
+ /**
+ * The associated content outline page.
+ */
+ private ContentOutlinePage outlinePage;
+
+ // Constructors ------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @param outlinePage the associated outline page
+ */
+ public CssOutlineDoubleClickListener(ContentOutlinePage outlinePage) {
+ this.outlinePage = outlinePage;
+ }
+
+ // IDoubleClickListener Implementation -------------------------------------
+
+ /*
+ * @see IDoubleClickListener#doubleClick(DoubleClickEvent)
+ */
+ public void doubleClick(DoubleClickEvent event) {
+ Object selectedElement = getSelectedElement(event.getSelection());
+ if (selectedElement instanceof IStyleRule) {
+ showPropertiesView();
+ }
+ }
+
+ // Private Methods ---------------------------------------------------------
+
+ /**
+ * Shows the properties view in the current workbench window.
+ */
+ private void showPropertiesView() {
+ IWorkbenchPage workbenchPage = outlinePage.getSite().getPage();
+ try {
+ workbenchPage.showView(IPageLayout.ID_PROP_SHEET);
+ } catch (PartInitException e) {
+ CssUI.log(
+ "Could not show properties view", e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Finds the element that is selected. As this is a double click listener,
+ * only a single element can be selected at once.
+ *
+ * @param selection the selection
+ * @return the selected element
+ */
+ private Object getSelectedElement(ISelection selection) {
+ Object element = null;
+ if (selection instanceof IStructuredSelection) {
+ element = ((IStructuredSelection) selection).getFirstElement();
+ }
+ return element;
+ }
+
+}