Author: mareshkau
Date: 2009-03-02 15:04:53 -0500 (Mon, 02 Mar 2009)
New Revision: 13927
Added:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/WizardNewCssClassPage.java
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/WebUIMessages.java
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/messages.properties
Removed:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/WebUIMessages.java
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/messages.properties
Modified:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/FileExtensionFilter.java
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3869
Modified:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-03-02
20:00:10 UTC (rev 13926)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-03-02
20:04:53 UTC (rev 13927)
@@ -26,7 +26,7 @@
BUTTON_CLEAR=Clear
BUTTON_ADD_NEW_STYLE_CLASS=Add CSS Class
ENTER_CSS_CLASS_NAME=Enter New CSS Class Name
-CSS_CLASS_NAME_NOT_VALID=CSS Class Name not valid
+CSS_CLASS_NAME_NOT_VALID=CSS Class Name is not valid
IMAGE_COMBO_TABLE_TOOL_TIP=Double click to select color
Modified:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2009-03-02
20:00:10 UTC (rev 13926)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2009-03-02
20:04:53 UTC (rev 13927)
@@ -26,7 +26,6 @@
import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.contentassist.JSPDialogCellEditorContentAssistProcessor;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.RootElement;
-import org.jboss.tools.jst.jsp.outline.cssdialog.CSSClassDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.CSSStyleDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
@@ -139,17 +138,18 @@
context.put("value", value);
attributeName = attributeName.toLowerCase();
- if (attributeName.equalsIgnoreCase(CSSConstants.CLASS)
- || attributeName.endsWith(CSSConstants.CLASS.toLowerCase())) {
- CSSClassDialog dialog = new CSSClassDialog(cellEditorWindow.getShell(), null,
false);
- dialog.setCurrentStyleClass(value);
-
- if (dialog.open() == Window.OK) {
- externalEditing = false;
-
- return dialog.getSelectorName();
- }
- } else if (attributeName.equalsIgnoreCase(CSSConstants.STYLE)
+// if (attributeName.equalsIgnoreCase(CSSConstants.CLASS)
+// || attributeName.endsWith(CSSConstants.CLASS.toLowerCase())) {
+// CSSClassDialog dialog = new CSSClassDialog(cellEditorWindow.getShell(),
null, false);
+// dialog.setCurrentStyleClass(value);
+//
+// if (dialog.open() == Window.OK) {
+// externalEditing = false;
+//
+// return dialog.getSelectorName();
+// }
+// } else
+ if (attributeName.equalsIgnoreCase(CSSConstants.STYLE)
|| attributeName.endsWith(CSSConstants.STYLE.toLowerCase())) {
CSSStyleDialog dialog = new CSSStyleDialog(cellEditorWindow.getShell(),
((value == null) ? Constants.EMPTY : value));
Modified:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2009-03-02
20:00:10 UTC (rev 13926)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/CSSClassDialog.java 2009-03-02
20:04:53 UTC (rev 13927)
@@ -164,7 +164,7 @@
if (currentFile == null) {
currentFile = Util.getActiveCssFile();
}
- currentClassStyle = Util.getActivePageCSSSelectorIfAny();
+// currentClassStyle = Util.getActivePageCSSSelectorIfAny();
}
/**
@@ -484,7 +484,7 @@
* Add New Class to CSS Class Dialog
* @param styleClassName - name of new style class
*/
- protected void addNewStyleClass(String styleClassName) {
+ public void addNewStyleClass(String styleClassName) {
applyButton.setEnabled(true);
styleChanged = true;
currentClassStyle = styleClassName;
@@ -493,9 +493,11 @@
styleComposite.updatePreview(currentClassStyle);
updateOKButtonState();
// add new class to end of list
- classCombo.add(currentClassStyle);
+ if (classCombo.indexOf(currentClassStyle) == -1)
+ classCombo.add(currentClassStyle);
// end select it
classCombo.select(classCombo.getItemCount() - 1);
+ cssModel.setCSS(currentClassStyle, styleAttributes);
}
// /**
// * This method is invoked to correctly process class style combo modify event.
@@ -618,12 +620,12 @@
currentClassStyle = classCombo.getText().trim();
// if new css was added
- if (classCombo.indexOf(currentClassStyle) == -1) {
- classCombo.add(currentClassStyle);
+// if (classCombo.indexOf(currentClassStyle) == -1) {
+// classCombo.add(currentClassStyle);
// styleChanged = true;
- } /*else {
- styleChanged = false;
- }*/
+// } else {
+// styleChanged = false;
+// }
applyButton.setEnabled(true);
styleChanged = true;
@@ -649,8 +651,9 @@
if (file != null) {
// create CSS Model
cssModel = new CSSModel(file);
+ currentClassStyle = null;
+ classCombo.removeAll();
classCombo.setEnabled(true);
- classCombo.removeAll();
// set file path to corresponding text field
if (useRelativePathPath) {
text.setText(file.getProjectRelativePath().toOSString());
@@ -665,19 +668,19 @@
// fill in ComboBox component with CSS model selectors
// List<Selector> selectors = cssModel.getSelectors();
List<String> selectors = cssModel.getSelectorLabels();
- int selectedIndex = -1;
for (int i = 0; i < selectors.size(); i++) {
// Selector value = selectors.get(i);
String label = selectors.get(i);
classCombo.add(/*value.getValue()*/ label);
- if (currentClassStyle != null &&
currentClassStyle.equals(/*value.getValue()*/label)) {
- selectedIndex = i;
- }
+
}
- if (currentClassStyle != null && selectedIndex == -1) {
+ /*
+ *
+ */
+ if (currentClassStyle != null) {
classCombo.setText(currentClassStyle);
} else {
- classCombo.select(selectedIndex);
+ classCombo.select(0);
}
classCombo.setToolTipText(cssModel.getCSSText(currentClassStyle));
@@ -790,8 +793,10 @@
public void releaseResources() {
- if (cssModel != null)
+ if (cssModel != null){
cssModel.releaseModel();
+ cssModel = null;
+ }
}
/**
@@ -920,13 +925,13 @@
}
}
}
-// /**
-// * Create a message string for user
-// * @param currentFile
-// * @return
-// */
-// private static final String getMessageForSaveDialog(IFile currentFile){
-// String userMessage ="'" + currentFile.getFullPath().toOSString() +
"' " + JstUIMessages.CSS_SAVE_DIALOG_MESSAGE; //$NON-NLS-1$//$NON-NLS-2$
-// return userMessage;
-// }
+
+ public void reinit(){
+ releaseResources();
+ initCSSModel(currentFile, true,true);
+ }
+
+ public void setCurrentFile(IFile currentFile) {
+ this.currentFile = currentFile;
+ }
}
Modified:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2009-03-02
20:00:10 UTC (rev 13926)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2009-03-02
20:04:53 UTC (rev 13927)
@@ -65,6 +65,7 @@
private CSSStyleSheet styleSheet = null;
private ICSSStyleSheet eclipseStyleSheet = null;
private String COPY_SUFFIX = "_copy";
+ private boolean copy = false;
/**
@@ -82,6 +83,7 @@
if (model != null) {
releaseModel();
}
+ copy = false;
formatProcessorCSS = new FormatProcessorCSS();
IModelManager modelManager = StructuredModelManager.getModelManager();
model = modelManager.getExistingModelForEdit(styleFile);
@@ -90,7 +92,8 @@
if (model == null)
model = modelManager.getModelForEdit(styleFile);
else {
-
+
+ copy = true;
// copy the model
model = modelManager.copyModelForEdit(model.getId(), model
.getId()
@@ -318,12 +321,21 @@
public void saveModel() {
try {
- // it is necessary not to dialog appears when "dirty" css file is
- // being saved
- IFileBuffer buffer = FileBuffers.getTextFileBufferManager()
- .getFileBuffer(styleFile.getFullPath(),
- LocationKind.NORMALIZE);
- buffer.setDirty(false);
+ /*
+ * it is necessary not to dialog appears when "dirty" css file is
+ * being saved ( test case : 1) open css file 2) make same changes
+ * 3) open css dialog 4) make some changes 5)press ok )
+ *
+ *
+ * it is necessary to distinguish real model from copy. For real
+ * model next step reject all changes
+ */
+ if (copy) {
+ IFileBuffer buffer = FileBuffers.getTextFileBufferManager()
+ .getFileBuffer(styleFile.getFullPath(),
+ LocationKind.NORMALIZE);
+ buffer.setDirty(false);
+ }
model.save();
} catch (IOException e) {
Modified:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/FileExtensionFilter.java
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/FileExtensionFilter.java 2009-03-02
20:00:10 UTC (rev 13926)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/FileExtensionFilter.java 2009-03-02
20:04:53 UTC (rev 13927)
@@ -41,8 +41,7 @@
}
}
return false;
- }
- if (element instanceof IProject && ((IProject) element).isOpen())
+ } if (element instanceof IProject && ((IProject) element).isOpen())
return true;
if (element instanceof IContainer) { // i.e. IProject, IFolder
try {
Modified:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java 2009-03-02
20:00:10 UTC (rev 13926)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/tabs/TabQuickEditControl.java 2009-03-02
20:04:53 UTC (rev 13927)
@@ -114,7 +114,7 @@
if(listKeys.size()==0) {
label = new Label(this, SWT.CENTER);
label.setText(JstUIMessages.CSS_NO_EDITED_PROPERTIES);
- }
+ }
Collections.sort(listKeys);
updateDataFromStyleAttributes = true;
for (String key : listKeys) {
Modified:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java 2009-03-02
20:00:10 UTC (rev 13926)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/NewCSSClassWizard.java 2009-03-02
20:04:53 UTC (rev 13927)
@@ -10,10 +10,14 @@
******************************************************************************/
package org.jboss.tools.jst.web.ui.wizards.css;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IPageChangedListener;
+import org.eclipse.jface.dialogs.PageChangedEvent;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
@@ -24,13 +28,14 @@
import org.jboss.tools.jst.jsp.outline.cssdialog.CSSClassDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.MessageDialogEvent;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.MessageDialogListener;
+import org.jboss.tools.jst.web.ui.wizards.messages.WebUIMessages;
/**
* New CSS class wizard.
*/
public class NewCSSClassWizard extends Wizard implements INewWizard {
- private static final String WIZARD_WINDOW_TITLE = "CSS Style Class
Editor";
+ private CSSClassDescription classDescription = new CSSClassDescription();
// workbench selection when the wizard was started
protected IStructuredSelection selection;
@@ -38,18 +43,20 @@
protected IWorkbench workbench;
// wizard contains only one page
- private NewCSSClassWizardPage page;
+ private NewCSSClassWizardPage editFilePage;
- /**
- * Constructor for SampleNewWizard.
- */
- public NewCSSClassWizard() {
- super();
- setWindowTitle(WIZARD_WINDOW_TITLE);
-
- }
+ private WizardNewCssClassPage selectFilePage;
/**
+ * Constructor for SampleNewWizard.
+ */
+ public NewCSSClassWizard() {
+ super();
+ setWindowTitle(WebUIMessages.WIZARD_WINDOW_TITLE);
+ }
+
+
+ /**
* @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
@@ -57,138 +64,175 @@
this.selection = selection;
}
- /**
- * Adding the page to the wizard.
- */
- @Override
+ /**
+ * Adding the page to the wizard.
+ */
+ @Override
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.
- */
- @Override
+ selectFilePage = new WizardNewCssClassPage(classDescription);
+ editFilePage = new NewCSSClassWizardPage();
+ addPage(selectFilePage);
+ addPage(editFilePage);
+ }
+
+ /**
+ * 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.
+ */
+ @Override
public boolean performFinish() {
- page.saveChanges();
+ editFilePage.saveChanges();
- return true;
- }
+ return true;
+ }
- /**
- * @see org.eclipse.jface.wizard.IWizard#canFinish()
- */
- @Override
+ /**
+ * @see org.eclipse.jface.wizard.IWizard#canFinish()
+ */
+ @Override
public boolean canFinish() {
- return page.canFinish;
+ return selectFilePage.canFlipToNextPage()
+ && getContainer().getCurrentPage() == editFilePage
+ && editFilePage.canFinish;
}
- /**
- * @see org.eclipse.jface.wizard.IWizard#performCancel()
- */
- @Override
- public boolean performCancel() {
- page.cancel();
- return true;
- }
+ /**
+ * @see org.eclipse.jface.wizard.IWizard#performCancel()
+ */
+ @Override
+ public boolean performCancel() {
+ editFilePage.cancel();
+ return true;
+ }
+
+ public class CSSClassDescription{
+ private IFile cssFile;
+ private String cssClassName;
+ public IFile getCssFile() {
+ return cssFile;
+ }
+ public void setCssFile(IFile cssFile) {
+ this.cssFile = cssFile;
+ }
+ public String getCssClassName() {
+ return cssClassName;
+ }
+ public void setCssClassName(String cssClassName) {
+ this.cssClassName = cssClassName;
+ }
+ }
- /**
- * Class representing the first page of the wizard.
- */
- private class NewCSSClassWizardPage extends WizardPage {
+ /**
+ * Class representing the first page of the wizard.
+ */
+ private class NewCSSClassWizardPage extends WizardPage {
- // TODO: take out to the property manager file
- final static String WIZARD_TITLE = "CSS Class";
- final static String WIZARD_DESCRIPTION = "Create New CSS Class";
+ private CSSClassDialog dialog;
- private CSSClassDialog dialog;
+ boolean canFinish = false;
- boolean canFinish = false;
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param pageName
+ */
+ public NewCSSClassWizardPage() {
+ super("newCSSClassWizard");
+ setTitle(WebUIMessages.WIZARD_TITLE);
+ setDescription(WebUIMessages.WIZARD_DESCRIPTION);
+
+ }
- /**
- * 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.NONE);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
- /**
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
-
- // Initialize CSS dialog that is integrated to CSS wizard.
- // Also it can be used separately without integration to wizard component.
- dialog = new CSSClassDialog(getShell(), selection, true);
- dialog.addMessageDialogListener(new MessageDialogListener() {
+ // Initialize CSS dialog that is integrated to CSS wizard.
+ // Also it can be used separately without integration to wizard
+ // component.
+ dialog = new CSSClassDialog(getShell(), selection, true);
+ dialog.addMessageDialogListener(new MessageDialogListener() {
public void throwMessage(MessageDialogEvent event) {
if (event != null) {
IStatus status = event.getOperationStatus();
if (status != null) {
applyToStatusLine(status);
}
- getWizard().getContainer().updateButtons();
+ getWizard().getContainer().updateButtons();
}
}
- });
- dialog.createDialog(container);
- setControl(container);
+ });
- }
+ dialog.createDialog(container);
+ setControl(container);
+
+ if (getWizard().getContainer() instanceof WizardDialog){
+ WizardDialog wd = (WizardDialog) getWizard().getContainer();
+ wd.addPageChangedListener(new IPageChangedListener(){
- /**
- * Save page model.
- */
- public void saveChanges() {
- dialog.saveChanges(true);
- }
+ //set console configuration as treeViewer input
+ public void pageChanged(PageChangedEvent event) {
+ if (event.getSelectedPage() == editFilePage){
+ dialog.setCurrentFile(classDescription.getCssFile());
+ dialog.reinit();
+ dialog.addNewStyleClass(classDescription.cssClassName);
+ }
+ }});
+ }
- /**
- * Handle cancel operation correctly.
- */
- public void cancel() {
- dialog.closeDialog();
- }
+ }
- /**
- * Applies the status to the status line of a dialog page.
- */
- private void applyToStatusLine(IStatus status) {
- String message= status.getMessage();
- if (message.length() == 0) {
- message = null;
- }
- switch (status.getSeverity()) {
- case IStatus.OK:
- setErrorMessage(null);
- setMessage(message);
- canFinish = true;
- break;
- case IStatus.WARNING:
- setErrorMessage(null);
- canFinish = true;
- setMessage(message, WizardPage.WARNING);
- break;
- case IStatus.INFO:
- setErrorMessage(null);
- canFinish = true;
- setMessage(message, WizardPage.INFORMATION);
- break;
- default:
- setErrorMessage(message);
- setMessage(null);
- canFinish = false;
- break;
- }
- }
- }
+ /**
+ * Save page model.
+ */
+ public void saveChanges() {
+// dialog.saveChanges(true);
+ dialog.close();
+ }
+
+ /**
+ * Handle cancel operation correctly.
+ */
+ public void cancel() {
+ dialog.closeDialog();
+ }
+
+ /**
+ * Applies the status to the status line of a dialog page.
+ */
+ private void applyToStatusLine(IStatus status) {
+ String message = status.getMessage();
+ if (message.length() == 0) {
+ message = null;
+ }
+ switch (status.getSeverity()) {
+ case IStatus.OK:
+ setErrorMessage(null);
+ setMessage(message);
+ canFinish = true;
+ break;
+ case IStatus.WARNING:
+ setErrorMessage(null);
+ canFinish = true;
+ setMessage(message, WizardPage.WARNING);
+ break;
+ case IStatus.INFO:
+ setErrorMessage(null);
+ canFinish = true;
+ setMessage(message, WizardPage.INFORMATION);
+ break;
+ default:
+ setErrorMessage(message);
+ setMessage(null);
+ canFinish = false;
+ break;
+ }
+ }
+ }
+
}
Copied:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/WizardNewCssClassPage.java
(from rev 13915,
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/WizardNewCssClassPage.java)
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/WizardNewCssClassPage.java
(rev 0)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/css/WizardNewCssClassPage.java 2009-03-02
20:04:53 UTC (rev 13927)
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jst.web.ui.wizards.css;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.BaseWorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.FileExtensionFilter;
+import org.jboss.tools.jst.web.ui.wizards.css.NewCSSClassWizard.CSSClassDescription;
+import org.jboss.tools.jst.web.ui.wizards.messages.WebUIMessages;
+import org.w3c.dom.css.CSSFontFaceRule;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class WizardNewCssClassPage extends WizardPage implements ModifyListener {
+
+ private final static String REQUIRED_FIELD_SIGN = "*"; //$NON-NLS-1$
+ private final static String CSS_FILE_EXTENSION = "css"; //$NON-NLS-1$
+ private CSSClassDescription classDescription;
+ private final static String[] fileExtensions = { CSS_FILE_EXTENSION };
+ private IFile currentFile;
+ private int numColumns = 3;
+ private Text selectFileText;
+ private Text classNameText;
+
+ /**
+ * @param pageName
+ */
+ public WizardNewCssClassPage(CSSClassDescription classDescription) {
+ super("WizardNewCssClassPage"); //$NON-NLS-1$
+ this.classDescription = classDescription;
+ setTitle(WebUIMessages.WIZARD_TITLE);
+ setDescription(WebUIMessages.WIZARD_DESCRIPTION);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = numColumns;
+ layout.makeColumnsEqualWidth = false;
+ container.setLayout(layout);
+
+ Label selectFileLabel = new Label(container, SWT.NONE);
+ selectFileLabel.setText(WebUIMessages.FILE_SELECT_LABEL
+ + REQUIRED_FIELD_SIGN);
+
+ selectFileText = new Text(container, SWT.SINGLE | SWT.BORDER);
+ selectFileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ selectFileText.setFont(parent.getFont());
+ selectFileText.addModifyListener(this);
+
+ Button selectFileButton = new Button(container, SWT.NONE);
+ selectFileButton.setText(WebUIMessages.FILE_SELECT_BUTTON);
+ selectFileButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+ getShell(), new WorkbenchLabelProvider(),
+ new BaseWorkbenchContentProvider());
+ dialog.addFilter(new FileExtensionFilter(fileExtensions));
+ dialog.setTitle(WebUIMessages.FILE_SELECT_DIALOG_TITLE);
+ dialog.setMessage(WebUIMessages.FILE_SELECT_DIALOG_MESSAGE);
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ dialog.setAllowMultiple(false);
+ dialog.setDoubleClickSelects(true);
+ dialog.setValidator(new ISelectionStatusValidator(){
+
+ public IStatus validate(Object[] selection) {
+ if(selection!=null && selection.length==1) {
+ if(selection[0] instanceof IFile) {
+ return new Status(IStatus.OK, PlatformUI.PLUGIN_ID,
+ IStatus.OK, "", //$NON-NLS-1$
+ null);
+ }
+ }
+ return new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID,
+ IStatus.ERROR, WebUIMessages.WIZARD_ERROR_FILE_SELECTION,
//$NON-NLS-1$
+ null);
+ }});
+ if (currentFile != null) {
+ dialog.setInitialSelection(currentFile);
+ }
+ dialog
+ .setEmptyListMessage(WebUIMessages.FILE_SELECT_DIALOG_EMPTY_MESSAGE);
+
+ if (dialog.open() == Window.OK) {
+ currentFile = (IFile) dialog.getFirstResult();
+ selectFileText
+ .setText(currentFile.getFullPath().toString());
+ }
+
+ }
+ });
+
+ Label classNameLabel = new Label(container, SWT.NONE);
+ classNameLabel.setText(WebUIMessages.CSS_CLASS_NAME_LABEL
+ + REQUIRED_FIELD_SIGN);
+
+ classNameText = new Text(container, SWT.SINGLE | SWT.BORDER);
+ classNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ classNameText.setFont(parent.getFont());
+ classNameText.addModifyListener(this);
+
+ setControl(container);
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ if ((classNameText.getText().length() != 0)
+ && (getCssFile(selectFileText.getText()) != null)) {
+ return true;
+ }
+ return false;
+ }
+
+ public void modifyText(ModifyEvent e) {
+
+ classDescription.setCssClassName(classNameText.getText());
+ classDescription.setCssFile(getCssFile(selectFileText.getText()));
+ getContainer().updateButtons();
+
+ }
+
+ private IFile getCssFile(String path) {
+ if (path != null) {
+ IResource cssFile = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(path);
+ if ((cssFile != null)
+ && (CSS_FILE_EXTENSION.equals(cssFile.getFileExtension()))) {
+ return (IFile) cssFile;
+ }
+ }
+ return null;
+ }
+
+}
Copied:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages
(from rev 13915,
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages)
Deleted:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/WebUIMessages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/WebUIMessages.java 2009-03-02
16:41:27 UTC (rev 13915)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/WebUIMessages.java 2009-03-02
20:04:53 UTC (rev 13927)
@@ -1,23 +0,0 @@
-package org.jboss.tools.jst.web.ui.wizards.messages;
-
-import org.eclipse.osgi.util.NLS;
-
-public class WebUIMessages extends NLS {
- private static final String BUNDLE_NAME =
"org.jboss.tools.jst.web.ui.wizards.messages.messages"; //$NON-NLS-1$
- public static String FILE_SELECT_DIALOG_EMPTY_MESSAGE;
- public static String FILE_SELECT_DIALOG_MESSAGE;
- public static String FILE_SELECT_DIALOG_TITLE;
- public static String FILE_SELECT_LABEL;
- public static String FILE_SELECT_BUTTON;
- public static String CSS_CLASS_NAME_LABEL;
- public static String WIZARD_WINDOW_TITLE;
- public static String WIZARD_TITLE;
- public static String WIZARD_DESCRIPTION;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, WebUIMessages.class);
- }
-
- private WebUIMessages() {
- }
-}
Copied:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/WebUIMessages.java
(from rev 13915,
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/WebUIMessages.java)
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/WebUIMessages.java
(rev 0)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/WebUIMessages.java 2009-03-02
20:04:53 UTC (rev 13927)
@@ -0,0 +1,24 @@
+package org.jboss.tools.jst.web.ui.wizards.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class WebUIMessages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.jst.web.ui.wizards.messages.messages"; //$NON-NLS-1$
+ public static String FILE_SELECT_DIALOG_EMPTY_MESSAGE;
+ public static String FILE_SELECT_DIALOG_MESSAGE;
+ public static String FILE_SELECT_DIALOG_TITLE;
+ public static String FILE_SELECT_LABEL;
+ public static String FILE_SELECT_BUTTON;
+ public static String CSS_CLASS_NAME_LABEL;
+ public static String WIZARD_WINDOW_TITLE;
+ public static String WIZARD_TITLE;
+ public static String WIZARD_DESCRIPTION;
+ public static String WIZARD_ERROR_FILE_SELECTION;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, WebUIMessages.class);
+ }
+
+ private WebUIMessages() {
+ }
+}
Deleted:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/messages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/messages.properties 2009-03-02
16:41:27 UTC (rev 13915)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/messages.properties 2009-03-02
20:04:53 UTC (rev 13927)
@@ -1,10 +0,0 @@
-FILE_SELECT_DIALOG_EMPTY_MESSAGE=No CSS file in the current project
-FILE_SELECT_DIALOG_MESSAGE=Select CSS file from the tree:
-FILE_SELECT_DIALOG_TITLE=CSS File Selection
-FILE_SELECT_LABEL=CSS File
-FILE_SELECT_BUTTON=Browse
-CSS_CLASS_NAME_LABEL=CSS Class
-WIZARD_WINDOW_TITLE=CSS Style Class Editor
-WIZARD_TITLE=CSS Class
-WIZARD_DESCRIPTION=Create New CSS Class
-
Copied:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/messages.properties
(from rev 13915,
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/messages.properties)
===================================================================
---
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/messages.properties
(rev 0)
+++
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/messages/messages.properties 2009-03-02
20:04:53 UTC (rev 13927)
@@ -0,0 +1,11 @@
+FILE_SELECT_DIALOG_EMPTY_MESSAGE=No CSS file in the current project
+FILE_SELECT_DIALOG_MESSAGE=Select CSS file from the tree:
+FILE_SELECT_DIALOG_TITLE=CSS File Selection
+FILE_SELECT_LABEL=CSS File
+FILE_SELECT_BUTTON=Browse
+CSS_CLASS_NAME_LABEL=CSS Class
+WIZARD_WINDOW_TITLE=CSS Style Class Editor
+WIZARD_TITLE=CSS Class
+WIZARD_DESCRIPTION=Create New CSS Class
+WIZARD_ERROR_FILE_SELECTION=No file specified
+