Author: dsakovich
Date: 2008-10-03 10:22:03 -0400 (Fri, 03 Oct 2008)
New Revision: 10660
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/images/xstudio/wizards/new_css_class.gif
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-2530
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2008-10-03 14:19:16 UTC
(rev 10659)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2008-10-03 14:22:03 UTC
(rev 10660)
@@ -62,5 +62,6 @@
org.eclipse.ui.views
Bundle-Version: 2.0.0
Export-Package: org.jboss.tools.jst.jsp.outline.cssdialog.common,
+ org.jboss.tools.jst.jsp.outline.cssdialog.events,
org.jboss.tools.jst.jsp.outline.cssdialog.parsers
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2008-10-03
14:19:16 UTC (rev 10659)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2008-10-03
14:22:03 UTC (rev 10660)
@@ -126,7 +126,7 @@
}
} else if (attributeName.endsWith("Class") ||
attributeName.endsWith("class") ) {
- CSSClassDialog dialog = new CSSClassDialog(cellEditorWindow.getShell());
+ CSSClassDialog dialog = new CSSClassDialog(cellEditorWindow.getShell(),false);
if (dialog.open() == Window.OK) {
externalEditing = false;
return dialog.getSelectorName();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-10-03
14:19:16 UTC (rev 10659)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2008-10-03
14:22:03 UTC (rev 10660)
@@ -16,6 +16,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
@@ -60,6 +62,7 @@
private Combo classCombo;
private CSSModel cssModel;
private String selectorName;
+ private boolean allProject;
final static int MIN_HEIGHT_FOR_BROWSER = 60;
final static String[] fileExtensions = { "css" };
@@ -68,22 +71,25 @@
final static String CSS_FILE_SELECT_DIALOG_EMPTY_MESSAGE = "No CSS file in the
current project";
final static String SKIP_FIRST_CHAR = ".";
- public CSSClassDialog(Shell parentShell) {
+ /**
+ *
+ * @param parentShell
+ * @param allProject (if allProject is true - browse css file in all projects, else
only in current project)
+ */
+ public CSSClassDialog(Shell parentShell,boolean allProject) {
super(parentShell);
+ this.allProject = allProject;
setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX
| SWT.APPLICATION_MODAL);
styleAttributes = new StyleAttributes();
}
/**
- * Method for creating dialog area
*
* @param parent
+ * @return
*/
- protected Control createDialogArea(final Composite parent) {
-
- final Composite composite = (Composite) super.createDialogArea(parent);
-
+ public Control createDialogComposite(Composite composite) {
GridLayout layout = new GridLayout();
layout.numColumns = 1;
composite.setLayout(layout);
@@ -110,8 +116,18 @@
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- IProject project = Util.getCurrentProject();
- IResource res = project.findMember(text.getText());
+ IResource res = null;
+ if (allProject) {
+ IWorkspace workspace = Util.getCurrentWorkspace();
+ if(workspace!=null) {
+ res = workspace.getRoot().findMember(text.getText());
+ }
+ } else {
+ IProject project = Util.getCurrentProject();
+ if (project!=null)
+ res = project.findMember(text.getText());
+ }
+
if (res != null) {
if (res instanceof IFile) {
file = (IFile) res;
@@ -171,7 +187,10 @@
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
- IProject project = Util.getCurrentProject();
+ IAdaptable project = Util.getCurrentWorkspace();
+ if (!allProject) {
+ project = Util.getCurrentProject();
+ }
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
getShell(), new WorkbenchLabelProvider(),
@@ -185,8 +204,11 @@
.setEmptyListMessage(CSS_FILE_SELECT_DIALOG_EMPTY_MESSAGE);
dialog.open();
IResource res = (IResource) dialog.getFirstResult();
- text.setText(res.getProjectRelativePath().toOSString());
-
+ if (allProject) {
+ text.setText(res.getFullPath().toOSString());
+ } else {
+ text.setText(res.getProjectRelativePath().toOSString());
+ }
}
});
@@ -216,8 +238,32 @@
return composite;
}
+
+ public void saveChanges() {
+ styleComposite.updateStyle();
+ String newStyle = styleComposite.getNewStyle();
+ cssModel.setCSS(classCombo.getText(), newStyle);
+ cssModel.saveModel();
+ }
+ public String getSelectorName() {
+ return selectorName;
+ }
+
/**
+ * Method for creating dialog area
+ *
+ * @param parent
+ *
+ */
+ protected Control createDialogArea(final Composite parent) {
+
+ final Composite composite = (Composite) super.createDialogArea(parent);
+
+ return createDialogComposite(composite);
+ }
+
+ /**
* Method for setting title for dialog
*
* @param newShell
@@ -228,10 +274,7 @@
}
protected void okPressed() {
- styleComposite.updateStyle();
- String newStyle = styleComposite.getNewStyle();
- cssModel.setCSS(classCombo.getText(), newStyle);
- cssModel.saveModel();
+ saveChanges();
String sel = classCombo.getText();
if (sel.trim().startsWith(SKIP_FIRST_CHAR)) {
sel = sel.substring(1);
@@ -239,9 +282,7 @@
selectorName = sel;
super.okPressed();
}
+
+
- public String getSelectorName() {
- return selectorName;
- }
-
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java 2008-10-03
14:19:16 UTC (rev 10659)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Util.java 2008-10-03
14:22:03 UTC (rev 10660)
@@ -17,6 +17,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -349,6 +350,24 @@
IProject project = file.getProject();
return project;
-
}
+
+ /**
+ * Get current workspace
+ *
+ * @return
+ */
+ public static IWorkspace getCurrentWorkspace() {
+ IEditorPart editor = JspEditorPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IEditorInput input = editor.getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput) input).getFile();
+ }
+ if (file == null)
+ return null;
+ IWorkspace workspace = file.getWorkspace();
+ return workspace;
+ }
}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2008-10-03 14:19:16
UTC (rev 10659)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2008-10-03 14:22:03
UTC (rev 10660)
@@ -85,6 +85,7 @@
org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.debug.ui,
- org.jboss.tools.jsf.vpe.jsf
+ org.jboss.tools.jsf.vpe.jsf,
+ org.jboss.tools.jst.jsp;bundle-version="2.0.0"
Bundle-Version: 2.0.0
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/images/xstudio/wizards/new_css_class.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/images/xstudio/wizards/new_css_class.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2008-10-03 14:19:16 UTC (rev
10659)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2008-10-03 14:22:03 UTC (rev
10660)
@@ -109,6 +109,21 @@
</wizard>
<wizard
category="org.jboss.tools.jst.web"
+ class="org.jboss.tools.jst.web.ui.wizards.css.NewCSSClassWizard"
+
finalPerspective="org.jboss.tools.jst.web.ui.WebDevelopmentPerspective"
+ icon="images/xstudio/wizards/new_css_class.gif"
+ id="org.jboss.tools.jst.web.ui.wizards.newfile.NewCSSClassWizard"
+ name="CSS Class"
+
preferredPerspectives="org.jboss.tools.jst.web.ui.WebDevelopmentPerspective"
+ project="false">
+ <description>
+ Create a CSS Class
+ </description>
+ <selection class="org.eclipse.core.resources.IResource">
+ </selection>
+ </wizard>
+ <wizard
+ category="org.jboss.tools.jst.web"
class="org.jboss.tools.jst.web.ui.wizards.newfile.NewJSFileWizard"
finalPerspective="org.jboss.tools.jst.web.ui.WebDevelopmentPerspective"
icon="images/xstudio/wizards/new_js_file.gif"
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java 2008-10-03
14:22:03 UTC (rev 10660)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.ui.wizards.css;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.jst.jsp.outline.cssdialog.CSSClassDialog;
+
+public class NewCSSClassWizard extends Wizard implements INewWizard {
+
+ private NewCSSClassWizardPage page;
+
+
+
+ /**
+ * Constructor for SampleNewWizard.
+ */
+ public NewCSSClassWizard() {
+ super();
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+
+ public void addPages() {
+ page = new NewCSSClassWizardPage();
+ addPage(page);
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in the wizard. We
+ * will create an operation and run it using wizard as execution context.
+ */
+ public boolean performFinish() {
+ page.saveChanges();
+ return true;
+ }
+
+ private class NewCSSClassWizardPage extends WizardPage {
+
+ private CSSClassDialog dialog;
+
+ final static String WIZARD_TITLE = "Create New CSS Class";
+ final static String WIZARD_DESCRIPTION = "Create New CSS Class";
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param pageName
+ */
+ public NewCSSClassWizardPage() {
+ super("newCSSClassWizard");
+ setTitle(WIZARD_TITLE);
+ setDescription(WIZARD_DESCRIPTION);
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+
+ dialog = new CSSClassDialog(getShell(), true);
+ dialog.createDialogComposite(container);
+ setControl(container);
+ }
+
+ public void saveChanges() {
+ dialog.saveChanges();
+ }
+ }
+
+}
\ No newline at end of file