Author: yzhishko
Date: 2010-03-26 12:23:10 -0400 (Fri, 26 Mar 2010)
New Revision: 21055
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/down.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/up.gif
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDragAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDropAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTreeDragAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/CSSSelectionEventManager.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDragListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTreeDragListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/CSSSelectorEventManager.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSSelectorPartComposite.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSSelectorPreview.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSStyleClassSelector.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSContainer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSJSPRecognizer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSRuleContainer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorTableModel.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorTreeModel.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorUtils.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSStyleSheetContainer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSTreeNode.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/ICSSClassSelectionChangedListener.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorFilter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTableContentProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTableViewer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeContentProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeLabelProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeViewer.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6067 - fixed. There are a lot of minor and
unpleasant bugs with preview updating and buttons blinking were fixed, too.
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/down.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/down.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/up.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/images/cssdialog/up.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -118,4 +118,6 @@
public static String PROPERTY_VALUE_COLUMN;
public static String CSS_ADD_CSS_CLASS_TIP;
public static String CSS_REMOVE_CSS_CLASS_TIP;
+ public static String CSS_MOVE_UP_CSS_CLASS_TIP;
+ public static String CSS_MOVE_DOWN_CSS_CLASS_TIP;
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2010-03-26
16:23:10 UTC (rev 21055)
@@ -8,6 +8,8 @@
CSS_INVALID_STYLE_PROPERTY=Invalid Style class property has been entered.
CSS_ADD_CSS_CLASS_TIP=Add CSS class
CSS_REMOVE_CSS_CLASS_TIP=Remove CSS class
+CSS_MOVE_UP_CSS_CLASS_TIP=Move Up
+CSS_MOVE_DOWN_CSS_CLASS_TIP=Move Down
#CSS_SAVE_DIALOG_TITLE=Save CSS file
CSS_CLASS_DIALOG_FILE_LABEL=CSS file:
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/Constants.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -60,6 +60,8 @@
public static final String IMAGE_FONTLARGE_FILE_LOCATION =
"images/cssdialog/font_large.gif"; //$NON-NLS-1$
public static final String IMAGE_LEFT_FILE_LOCATION =
"images/cssdialog/left.gif"; //$NON-NLS-1$
public static final String IMAGE_RIGHT_FILE_LOCATION =
"images/cssdialog/right.gif"; //$NON-NLS-1$
+ public static final String IMAGE_UP_FILE_LOCATION = "images/cssdialog/up.gif";
//$NON-NLS-1$
+ public static final String IMAGE_DOWN_FILE_LOCATION =
"images/cssdialog/down.gif"; //$NON-NLS-1$
public static final String IMAGE_SAMPLE_FILE_LOCATION =
"images/cssdialog/sample.gif"; //$NON-NLS-1$
public static final String IMAGE_STYLE_SHEET_LOCATION =
"images/cssdialog/style_sheet.gif"; //$NON-NLS-1$
public static final String IMAGE_STYLE_CLASS_LOCATION =
"images/cssdialog/style_class.gif"; //$NON-NLS-1$
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSSelectorPartComposite.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSSelectorPartComposite.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSSelectorPartComposite.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -13,15 +13,19 @@
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
+import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetAdapter;
@@ -39,8 +43,8 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
@@ -49,15 +53,18 @@
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.StyleAttributes;
-import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.dnd.CSSTableDragListener;
-import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.dnd.CSSTreeDragListener;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.dnd.CSSTableDragAdapter;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.dnd.CSSTableDropAdapter;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.dnd.CSSTreeDragAdapter;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSContainer;
import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSJSPRecognizer;
import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSRuleContainer;
import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSSelectorTableModel;
import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSSelectorTreeModel;
+import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSStyleSheetContainer;
import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSTreeNode;
import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.selection.CSSClassSelectionChangedEvent;
-import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.selection.CSSSelectorEventManager;
+import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.selection.CSSSelectionEventManager;
import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.selection.ICSSClassSelectionChangedListener;
import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.viewers.CSSSelectorFilter;
import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.viewers.CSSSelectorTableViewer;
@@ -77,9 +84,12 @@
private static final int VIEWER_WIDTH = 175;
/** Existing font family */
- Composite buttonsContainer;
+ private Composite moveButtonsContainer;
+ private Composite tableButtonsContainer;
private Button rightButton;
private Button leftButton;
+ private Button upButton;
+ private Button downButton;
private String setClasses;
private CSSSelectorTreeViewer allCSSStyleClassViewer;
private CSSSelectorTableViewer selectedClassesTableViewer;
@@ -96,15 +106,6 @@
this.setClasses = setClasses;
this.styleAttributes = styleAttributes;
creatSelectorPart();
- addDisposeListener(new DisposeListener() {
-
- public void widgetDisposed(DisposeEvent e) {
- for (int i = 0; i < changedListeners.size(); i++) {
- removeCSSClassSelectionChangedListener(changedListeners
- .get(i));
- }
- }
- });
}
private void creatSelectorPart() {
@@ -139,11 +140,11 @@
Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
allCSSStyleClassViewer.addDragSupport(DND.DROP_MOVE, types,
- new CSSTreeDragListener(this, allCSSStyleClassViewer,
+ new CSSTreeDragAdapter(this, allCSSStyleClassViewer,
selectedClassesTableViewer));
selectedClassesTableViewer.addDragSupport(DND.DROP_MOVE, types,
- new CSSTableDragListener(this, allCSSStyleClassViewer,
+ new CSSTableDragAdapter(this, allCSSStyleClassViewer,
selectedClassesTableViewer));
allCSSStyleClassViewer.addDropSupport(DND.DROP_MOVE, types,
@@ -160,49 +161,21 @@
});
selectedClassesTableViewer.addDropSupport(DND.DROP_MOVE, types,
- new DropTargetAdapter() {
- @Override
- public void drop(DropTargetEvent event) {
- if (event.data == null
- || event.data
- .equals(CSSSelectorTableViewer.CSS_SELECTOR_TABLE_VIWER_ID)) {
- event.detail = DND.DROP_NONE;
- return;
- }
- }
- });
+ new CSSTableDropAdapter(this, allCSSStyleClassViewer,
+ selectedClassesTableViewer));
}
private void initListeners() {
- final Tree tree = allCSSStyleClassViewer.getTree();
allCSSStyleClassViewer
.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
- TreeItem[] selectedItems = tree.getSelection();
- if (selectedItems != null && selectedItems.length > 0) {
- TreeItem selectedItem = selectedItems[selectedItems.length - 1];
- CSSTreeNode treeNode = (CSSTreeNode) selectedItem
- .getData();
- if (!(treeNode.getCSSContainer() instanceof CSSRuleContainer)) {
- if (allCSSStyleClassViewer
- .getExpandedState(treeNode)) {
- allCSSStyleClassViewer.collapseToLevel(
- treeNode, 1);
- return;
- }
- allCSSStyleClassViewer.expandToLevel(treeNode,
- 1);
- return;
- }
- selectedClassesTableViewer.add(treeNode.toString());
- updateStyles();
- }
+ handleAddClass();
}
});
-
+
selectedClassesTableViewer
.addDoubleClickListener(new IDoubleClickListener() {
@@ -217,6 +190,12 @@
public void selectionChanged(
final SelectionChangedEvent event) {
+ if (!CSSSelectionEventManager.getInstance()
+ .isHandleSelection()) {
+ CSSSelectionEventManager.getInstance()
+ .setHandleSelection(true);
+ return;
+ }
if (!event.getSelection().isEmpty()) {
rightButton.setEnabled(true);
leftButton.setEnabled(false);
@@ -224,22 +203,36 @@
rightButton.setEnabled(false);
leftButton.setEnabled(false);
}
- Thread thread = new Thread("TreeSelectorWorker") { //$NON-NLS-1$
- @Override
+ selectedClassesTableViewer.getTable().deselectAll();
+ checkForTableMove(event);
+ if (event.getSelection().isEmpty()) {
+ return;
+ }
+ Display.getCurrent().asyncExec(new Runnable() {
+
public void run() {
- fireClassSelectionChanged(CSSSelectorEventManager
- .getInstance().createTreeSelectionChangedEvent(
- event, allCSSStyleClassViewer.getModel()));
+ fireClassSelectionChanged(CSSSelectionEventManager
+ .getInstance()
+ .createTreeSelectionChangedEvent(
+ event,
+ allCSSStyleClassViewer
+ .getModel()));
}
- };
- thread.start();
+ });
}
});
selectedClassesTableViewer
.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(final SelectionChangedEvent event) {
+ public void selectionChanged(
+ final SelectionChangedEvent event) {
+ if (!CSSSelectionEventManager.getInstance()
+ .isHandleSelection()) {
+ CSSSelectionEventManager.getInstance()
+ .setHandleSelection(true);
+ return;
+ }
if (!event.getSelection().isEmpty()) {
rightButton.setEnabled(false);
leftButton.setEnabled(true);
@@ -247,56 +240,114 @@
rightButton.setEnabled(false);
leftButton.setEnabled(false);
}
- Thread thread = new Thread("TableSelectorWorker") { //$NON-NLS-1$
- @Override
+ checkForTableMove(event);
+ allCSSStyleClassViewer.getTree().deselectAll();
+ if (event.getSelection().isEmpty()) {
+ return;
+ }
+ Display.getCurrent().asyncExec(new Runnable() {
+
public void run() {
- fireClassSelectionChanged(CSSSelectorEventManager
- .getInstance().createTableSelectionChangedEvent(
- event, allCSSStyleClassViewer.getModel()));
+ fireClassSelectionChanged(CSSSelectionEventManager
+ .getInstance()
+ .createTableSelectionChangedEvent(
+ event,
+ allCSSStyleClassViewer
+ .getModel()));
}
- };
- thread.start();
+ });
}
});
allCSSStyleClassViewer.getTree().addKeyListener(new KeyListener() {
-
+
public void keyReleased(KeyEvent e) {
if (SWT.ARROW_RIGHT == e.keyCode && SWT.ALT == e.stateMask) {
handleAddClass();
}
}
-
+
public void keyPressed(KeyEvent e) {
}
});
-
+
selectedClassesTableViewer.getTable().addKeyListener(new KeyListener() {
-
+
public void keyReleased(KeyEvent e) {
- if (SWT.ARROW_LEFT== e.keyCode && SWT.ALT == e.stateMask) {
+ if (SWT.ARROW_LEFT == e.keyCode && SWT.ALT == e.stateMask) {
handleRemoveClass();
}
}
-
+
public void keyPressed(KeyEvent e) {
}
});
-
+
rightButton.addSelectionListener(this);
leftButton.addSelectionListener(this);
+ upButton.addSelectionListener(this);
+ downButton.addSelectionListener(this);
}
+ private void checkForTableMove(SelectionChangedEvent event) {
+ if (event.getSelection().isEmpty()) {
+ upButton.setEnabled(false);
+ downButton.setEnabled(false);
+ return;
+ }
+ int[] selectionIndices = selectedClassesTableViewer.getTable()
+ .getSelectionIndices();
+ if (selectionIndices.length == 0) {
+ upButton.setEnabled(false);
+ downButton.setEnabled(false);
+ return;
+ }
+ if (!isSequencedIndices(selectionIndices)) {
+ upButton.setEnabled(true);
+ downButton.setEnabled(true);
+ } else {
+ if (selectionIndices[0] != 0
+ && (selectionIndices[selectionIndices.length - 1] !=
selectedClassesTableViewer
+ .getTable().getItemCount() - 1)) {
+ upButton.setEnabled(true);
+ downButton.setEnabled(true);
+ } else if (selectionIndices[0] != 0) {
+ downButton.setEnabled(false);
+ upButton.setEnabled(true);
+ } else if (selectionIndices[selectionIndices.length - 1] !=
selectedClassesTableViewer
+ .getTable().getItemCount() - 1) {
+ downButton.setEnabled(true);
+ upButton.setEnabled(false);
+ } else if (selectionIndices[0] == 0
+ && (selectionIndices[selectionIndices.length - 1] ==
selectedClassesTableViewer
+ .getTable().getItemCount() - 1)) {
+ upButton.setEnabled(false);
+ downButton.setEnabled(false);
+ }
+ }
+ }
+
+ private boolean isSequencedIndices(int[] indices) {
+ for (int i = 0; i < indices.length - 1; i++) {
+ if (indices[i + 1] - indices[i] != 1)
+ return false;
+ }
+ return true;
+ }
+
private void initControls() {
allCSSStyleClassViewer = new CSSSelectorTreeViewer(this, SWT.MULTI
| SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
filter = new CSSSelectorFilter();
allCSSStyleClassViewer.addFilter(filter);
- buttonsContainer = new Composite(this, SWT.NONE);
- rightButton = new Button(buttonsContainer, SWT.PUSH);
- leftButton = new Button(buttonsContainer, SWT.PUSH);
+ moveButtonsContainer = new Composite(this, SWT.NONE);
+ rightButton = new Button(moveButtonsContainer, SWT.PUSH);
+ leftButton = new Button(moveButtonsContainer, SWT.PUSH);
selectedClassesTableViewer = new CSSSelectorTableViewer(this, SWT.MULTI
| SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ tableButtonsContainer = new Composite(this, SWT.NONE);
+ upButton = new Button(tableButtonsContainer, SWT.PUSH);
+ downButton = new Button(tableButtonsContainer, SWT.PUSH);
rightButton.setToolTipText(JstUIMessages.CSS_ADD_CSS_CLASS_TIP);
ImageDescriptor rightDesc = JspEditorPlugin
.getImageDescriptor(Constants.IMAGE_RIGHT_FILE_LOCATION);
@@ -323,6 +374,32 @@
button.getImage().dispose();
}
});
+ upButton.setToolTipText(JstUIMessages.CSS_MOVE_UP_CSS_CLASS_TIP);
+
+ ImageDescriptor upDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_UP_FILE_LOCATION);
+ Image upImage = upDesc.createImage();
+ upButton.setImage(upImage);
+ upButton.setEnabled(false);
+ upButton.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
+ downButton.setToolTipText(JstUIMessages.CSS_MOVE_DOWN_CSS_CLASS_TIP);
+
+ ImageDescriptor downDesc = JspEditorPlugin
+ .getImageDescriptor(Constants.IMAGE_DOWN_FILE_LOCATION);
+ Image downImage = downDesc.createImage();
+ downButton.setImage(downImage);
+ downButton.setEnabled(false);
+ downButton.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ Button button = (Button) e.getSource();
+ button.getImage().dispose();
+ }
+ });
}
private String[] parseSetClasses() {
@@ -345,23 +422,83 @@
handleRemoveClass();
} else if (ob.equals(rightButton)) {
handleAddClass();
+ } else if (ob.equals(upButton)) {
+ handleMoveUp();
+ } else if (ob.equals(downButton)) {
+ handleMoveDown();
} else if (ob.equals(allCSSStyleClassViewer.getTree())) {
- selectedClassesTableViewer.getTable().deselectAll();
- leftButton.setEnabled(false);
- rightButton.setEnabled(true);
+ selectedClassesTableViewer.setSelection(new StructuredSelection());
} else if (ob.equals(selectedClassesTableViewer.getTable())) {
- allCSSStyleClassViewer.getTree().deselectAll();
- rightButton.setEnabled(false);
- leftButton.setEnabled(true);
+ allCSSStyleClassViewer.setSelection(new StructuredSelection());
}
}
+ private void handleMoveDown() {
+ StructuredSelection selection = (StructuredSelection) selectedClassesTableViewer
+ .getSelection();
+ Object[] selectedItems = selection.toArray();
+ int[] selectedIndices = selectedClassesTableViewer.getTable()
+ .getSelectionIndices();
+ int itemsCount = selectedClassesTableViewer.getTable().getItemCount();
+ int selectionLength = selectedIndices.length;
+ for (int i = 0; i < selectionLength; i++) {
+ CSSSelectionEventManager.getInstance().setHandleSelection(false);
+ selectedClassesTableViewer.remove(selectedItems[selectionLength - 1 - i]);
+ if (selectedIndices[selectionLength - 1 - i] == itemsCount - 1) {
+ TableItem item = new TableItem(selectedClassesTableViewer
+ .getTable(), selectedClassesTableViewer.getTable()
+ .getStyle(), itemsCount - 1);
+ item.setData(selectedItems[selectionLength - 1 - i]);
+ itemsCount--;
+ } else {
+ TableItem item = new TableItem(selectedClassesTableViewer
+ .getTable(), selectedClassesTableViewer.getTable()
+ .getStyle(),
+ selectedIndices[selectionLength - 1 - i] + 1);
+ item.setData(selectedItems[selectionLength - 1 - i]);
+ }
+ }
+ selectedClassesTableViewer.refresh();
+ selectedClassesTableViewer.setSelection(new StructuredSelection(
+ selectedItems));
+ }
+
+ private void handleMoveUp() {
+ StructuredSelection selection = (StructuredSelection) selectedClassesTableViewer
+ .getSelection();
+ Object[] selectedItems = selection.toArray();
+ int[] selectedIndices = selectedClassesTableViewer.getTable()
+ .getSelectionIndices();
+ CSSSelectionEventManager.getInstance().setHandleSelection(false);
+ selectedClassesTableViewer.remove(selection.toArray());
+ for (int i = 0; i < selectedIndices.length; i++) {
+ if (selectedIndices[i] == i) {
+ TableItem item = new TableItem(selectedClassesTableViewer
+ .getTable(), selectedClassesTableViewer.getTable()
+ .getStyle(), i);
+ item.setData(selectedItems[i]);
+ } else {
+ TableItem item = new TableItem(selectedClassesTableViewer
+ .getTable(), selectedClassesTableViewer.getTable()
+ .getStyle(), selectedIndices[i] - 1);
+ item.setData(selectedItems[i]);
+ }
+ }
+ selectedClassesTableViewer.refresh();
+ selectedClassesTableViewer.setSelection(new StructuredSelection(
+ selectedItems));
+ }
+
public void widgetSelected(SelectionEvent e) {
Object ob = e.getSource();
if (ob.equals(leftButton)) {
handleRemoveClass();
} else if (ob.equals(rightButton)) {
handleAddClass();
+ } else if (ob.equals(upButton)) {
+ handleMoveUp();
+ } else if (ob.equals(downButton)) {
+ handleMoveDown();
}
}
@@ -369,32 +506,42 @@
TableItem[] selectedItems = selectedClassesTableViewer.getTable()
.getSelection();
if (selectedItems != null && selectedItems.length > 0) {
+ List<String> itemsToRemove = new ArrayList<String>(0);
for (int i = 0; i < selectedItems.length; i++) {
- selectedClassesTableViewer.remove(selectedItems[i].getData());
+ itemsToRemove.add(selectedItems[i].getData().toString());
}
+ selectedClassesTableViewer.remove(itemsToRemove.toArray());
updateStyles();
}
}
private void handleAddClass() {
+ Set<String> itemsToMove = new LinkedHashSet<String>(0);
TreeItem[] selectedItems = allCSSStyleClassViewer.getTree()
.getSelection();
if (selectedItems != null && selectedItems.length > 0) {
for (int i = 0; i < selectedItems.length; i++) {
TreeItem item = selectedItems[i];
- if (!(((CSSTreeNode) item.getData()).getCSSContainer() instanceof CSSRuleContainer))
{
- continue;
+ CSSContainer container = ((CSSTreeNode) item.getData())
+ .getCSSContainer();
+ CSSTreeNode treeNode = (CSSTreeNode) item.getData();
+ if ((container instanceof CSSStyleSheetContainer)) {
+ List<CSSTreeNode> children = treeNode.getChildren();
+ for (int j = 0; j < children.size(); j++) {
+ itemsToMove.add(children.get(j).toString());
+ }
+ } else if (container instanceof CSSRuleContainer) {
+ itemsToMove.add(treeNode.toString());
}
- selectedClassesTableViewer.add(((CSSTreeNode) item.getData())
- .toString());
}
+ selectedClassesTableViewer.add(itemsToMove.toArray());
updateStyles();
}
}
private void createLayout() {
final GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
+ gridLayout.numColumns = 4;
setLayout(gridLayout);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
setLayoutData(gridData);
@@ -409,9 +556,9 @@
gridData.widthHint = VIEWER_WIDTH;
selectedClassesTableViewer.getTable().setLayoutData(gridData);
- final GridLayout btmContGridLayout = new GridLayout();
- btmContGridLayout.numColumns = 1;
- buttonsContainer.setLayout(btmContGridLayout);
+ final GridLayout moveBtnContGridLayout = new GridLayout();
+ moveBtnContGridLayout.numColumns = 1;
+ moveButtonsContainer.setLayout(moveBtnContGridLayout);
gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.widthHint = BUTTOND_WIDTH;
@@ -421,6 +568,9 @@
gridData.widthHint = BUTTOND_WIDTH;
leftButton.setLayoutData(gridData);
+ final GridLayout tableBtnContGridLayout = new GridLayout();
+ tableBtnContGridLayout.numColumns = 1;
+ tableButtonsContainer.setLayout(tableBtnContGridLayout);
}
public void updateStyles() {
@@ -442,10 +592,8 @@
}
}
allCSSStyleClassViewer.refresh();
- allCSSStyleClassViewer.getTree().deselectAll();
- selectedClassesTableViewer.getTable().deselectAll();
- rightButton.setEnabled(false);
- leftButton.setEnabled(false);
+ allCSSStyleClassViewer.setSelection(new StructuredSelection());
+ selectedClassesTableViewer.setSelection(new StructuredSelection());
}
public String getCSSStyleClasses() {
@@ -492,10 +640,16 @@
return selectedItemsList.toArray(new String[0]);
}
- private void fireClassSelectionChanged(CSSClassSelectionChangedEvent event) {
- for (int i = 0; i < changedListeners.size(); i++) {
- changedListeners.get(i).classSelectionChanged(event);
- }
+ private void fireClassSelectionChanged(
+ final CSSClassSelectionChangedEvent event) {
+ SafeRunner.run(new SafeRunnable() {
+ public void run() throws Exception {
+ for (int i = 0; i < changedListeners.size(); i++) {
+ changedListeners.get(i).classSelectionChanged(event);
+ }
+ }
+ });
+
}
public synchronized void addCSSClassSelectionChangedListener(
@@ -508,4 +662,13 @@
changedListeners.remove(listener);
}
+ @Override
+ public void dispose() {
+ for (int i = 0; i < changedListeners.size(); i++) {
+ removeCSSClassSelectionChangedListener(changedListeners.get(i));
+ }
+ changedListeners = null;
+ super.dispose();
+ }
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSSelectorPreview.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSSelectorPreview.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSSelectorPreview.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -1,10 +1,14 @@
package org.jboss.tools.jst.jsp.outline.cssdialog.cssselector;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IElementComparer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.wst.css.core.internal.modelhandler.CSSModelLoader;
import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
@@ -20,8 +24,9 @@
@SuppressWarnings("restriction")
public class CSSSelectorPreview extends Composite implements
- ICSSClassSelectionChangedListener {
+ ICSSClassSelectionChangedListener, IElementComparer {
+ private ISelection prevSelection;
private StructuredTextViewer viewer;
private ICSSModel model;
private ICSSStyleSheet styleSheet;
@@ -44,25 +49,34 @@
CSSModelLoader cssModelLoader = new CSSModelLoader();
IStructuredModel model = cssModelLoader.createModel();
this.model = (ICSSModel) model;
+ styleSheet = (ICSSStyleSheet) this.model.getDocument();
viewer.setDocument(model.getStructuredDocument());
viewer.setEditable(false);
}
public void classSelectionChanged(final CSSClassSelectionChangedEvent event) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- styleSheet = (ICSSStyleSheet) model.getDocument();
- CSSRuleContainer[] containers = event
- .getSelectedRuleContainers();
- if (containers.length != 0) {
- clearPreview();
- for (int i = 0; i < containers.length; i++) {
- appendRuleFromContainer(containers[i]);
- }
+ CSSRuleContainer[] containers = event.getSelectedRuleContainers();
+ if (containers.length != 0) {
+ List<CSSRuleContainer> ruleContainerList = new
ArrayList<CSSRuleContainer>(0);
+ for (int i = 0; i < containers.length; i++) {
+ ruleContainerList.add(containers[i]);
+ }
+ ISelection newSelection = new StructuredSelection(ruleContainerList, this);
+ if (prevSelection == null) {
+ prevSelection = new StructuredSelection(ruleContainerList, this);
+ clearPreview();
+ for (int i = 0; i < containers.length; i++) {
+ appendRuleFromContainer(containers[i]);
}
}
- });
-
+ if (!prevSelection.equals(newSelection)) {
+ clearPreview();
+ for (int i = 0; i < containers.length; i++) {
+ appendRuleFromContainer(containers[i]);
+ }
+ prevSelection = newSelection;
+ }
+ }
}
private void appendRuleFromContainer(CSSRuleContainer container) {
@@ -81,4 +95,12 @@
}
}
+ public boolean equals(Object a, Object b) {
+ return a.equals(b);
+ }
+
+ public int hashCode(Object element) {
+ return 0;
+ }
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSStyleClassSelector.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSStyleClassSelector.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/CSSStyleClassSelector.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -94,5 +94,5 @@
private CSSSelectorPreview createPreviewComposite(Composite parent) {
return new CSSSelectorPreview(parent);
}
-
+
}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDragAdapter.java
(from rev 21000,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDragListener.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDragAdapter.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDragAdapter.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.jsp.outline.cssdialog.cssselector.dnd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Tree;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.CSSSelectorPartComposite;
+import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.viewers.CSSSelectorTableViewer;
+
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
+@SuppressWarnings("unused")
+public class CSSTableDragAdapter implements DragSourceListener {
+
+ private Table table;
+ private Tree tree;
+ private CSSSelectorPartComposite parent;
+ private TreeViewer treeViewer;
+ private TableViewer tableViewer;
+
+ public CSSTableDragAdapter(CSSSelectorPartComposite parent,
+ TreeViewer treeViewer, TableViewer tableViewer) {
+ this.table = tableViewer.getTable();
+ this.tree = treeViewer.getTree();
+ this.treeViewer = treeViewer;
+ this.tableViewer = tableViewer;
+ this.parent = parent;
+ }
+
+ public void dragStart(DragSourceEvent event) {
+ event.doit = table.getSelectionCount() > 0;
+ }
+
+ public void dragSetData(DragSourceEvent event) {
+ List<String> selectedItems = new ArrayList<String>(0);
+ TableItem[] selectedTableItems = table.getSelection();
+ if (selectedTableItems != null) {
+ for (int i = 0; i < selectedTableItems.length; i++) {
+ selectedItems.add(selectedTableItems[i].getData().toString());
+ }
+ }
+ event.data = CSSSelectorTableViewer.CSS_SELECTOR_TABLE_VIWER_ID;
+ }
+
+ public void dragFinished(DragSourceEvent event) {
+ if (event.detail == DND.DROP_MOVE) {
+ TableItem[] selectedTableItems = table.getSelection();
+ if (selectedTableItems != null && selectedTableItems.length > 0) {
+ for (int i = 0; i < selectedTableItems.length; i++) {
+ tableViewer.remove(selectedTableItems[i].getData());
+ }
+ }
+ parent.updateStyles();
+ }
+ }
+
+}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDragListener.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDragListener.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDragListener.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2010 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.jsp.outline.cssdialog.cssselector.dnd;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Tree;
-import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.CSSSelectorPartComposite;
-import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.viewers.CSSSelectorTableViewer;
-
-/**
- *
- * @author yzhishko
- *
- */
-
-@SuppressWarnings("unused")
-public class CSSTableDragListener implements DragSourceListener {
-
- private Table table;
- private Tree tree;
- private CSSSelectorPartComposite parent;
- private TreeViewer treeViewer;
- private TableViewer tableViewer;
-
- public CSSTableDragListener (CSSSelectorPartComposite parent, TreeViewer treeViewer,
TableViewer tableViewer){
- this.table = tableViewer.getTable();
- this.tree = treeViewer.getTree();
- this.treeViewer = treeViewer;
- this.tableViewer = tableViewer;
- this.parent = parent;
- }
-
- public void dragStart(DragSourceEvent event) {
- event.doit = table.getSelectionCount() > 0;
- }
-
- public void dragSetData(DragSourceEvent event) {
- List<String> selectedItems = new ArrayList<String>(0);
- TableItem[] selectedTableItems = table.getSelection();
- if (selectedTableItems != null) {
- for (int i = 0; i < selectedTableItems.length; i++) {
- selectedItems.add(selectedTableItems[i].getData()
- .toString());
- }
- }
- event.data = CSSSelectorTableViewer.CSS_SELECTOR_TABLE_VIWER_ID;
- }
-
- public void dragFinished(DragSourceEvent event) {
- if (event.detail == DND.DROP_MOVE) {
- TableItem[] selectedTableItems = table.getSelection();
- if (selectedTableItems != null && selectedTableItems.length > 0) {
- for (int i = 0; i < selectedTableItems.length; i++) {
- tableViewer.remove(selectedTableItems[i].getData());
- }
- }
- parent.updateStyles();
- }
- }
-
-}
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDropAdapter.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDropAdapter.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTableDropAdapter.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.jsp.outline.cssdialog.cssselector.dnd;
+
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetAdapter;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.TreeItem;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.CSSSelectorPartComposite;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSContainer;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSRuleContainer;
+import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSStyleSheetContainer;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSTreeNode;
+import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.selection.CSSSelectionEventManager;
+import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.viewers.CSSSelectorTableViewer;
+import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.viewers.CSSSelectorTreeViewer;
+
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
+public class CSSTableDropAdapter extends DropTargetAdapter {
+
+ private TableViewer tableViewer;
+ private CSSSelectorPartComposite parent;
+ private TreeViewer treeViewer;
+
+ public CSSTableDropAdapter(CSSSelectorPartComposite parent,
+ TreeViewer treeViewer, TableViewer tableViewer) {
+ this.treeViewer = treeViewer;
+ this.tableViewer = tableViewer;
+ this.parent = parent;
+ }
+
+ @Override
+ public void drop(DropTargetEvent event) {
+ if (event.data == null) {
+ event.detail = DND.DROP_NONE;
+ } else if (event.data
+ .equals(CSSSelectorTableViewer.CSS_SELECTOR_TABLE_VIWER_ID)) {
+ handleTableSelectionMove(event);
+ event.detail = DND.DROP_NONE;
+ } else if (event.data
+ .equals(CSSSelectorTreeViewer.CSS_SELECTOR_TREE_VIWER_ID)) {
+ handleTreeSelectionMove(event);
+ event.detail = DND.DROP_NONE;
+ }
+ }
+
+ protected void handleTreeSelectionMove(DropTargetEvent event) {
+ Set<String> itemsToMove = new LinkedHashSet<String>(0);
+ TreeItem[] selectedItems = treeViewer.getTree().getSelection();
+ if (selectedItems != null && selectedItems.length > 0) {
+ for (int i = 0; i < selectedItems.length; i++) {
+ TreeItem item = selectedItems[i];
+ CSSContainer container = ((CSSTreeNode) item.getData())
+ .getCSSContainer();
+ CSSTreeNode treeNode = (CSSTreeNode) item.getData();
+ if ((container instanceof CSSStyleSheetContainer)) {
+ List<CSSTreeNode> children = treeNode.getChildren();
+ for (int j = 0; j < children.size(); j++) {
+ itemsToMove.add(((CSSTreeNode) children.get(j))
+ .toString());
+ }
+ } else if (container instanceof CSSRuleContainer) {
+ itemsToMove.add(treeNode.toString());
+ }
+ }
+ filterExistingItems(itemsToMove);
+ if (itemsToMove.size() != 0) {
+ if (event.item == null) {
+ handleEndInsertFromTree(itemsToMove, event);
+ } else {
+ handleMiddleInsertFromTree(itemsToMove, event);
+ }
+ parent.updateStyles();
+ }
+ }
+ }
+
+ protected void filterExistingItems(Set<String> itemsSet) {
+ Object[] items = itemsSet.toArray();
+ for (int i = 0; i < items.length; i++) {
+ if (isContain(items[i])) {
+ itemsSet.remove(items[i]);
+ }
+ }
+ }
+
+ private boolean isContain(Object element) {
+ TableItem[] items = tableViewer.getTable().getItems();
+ if (items != null) {
+ for (int i = 0; i < items.length; i++) {
+ if (element.equals(items[i].getData())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected void handleEndInsertFromTree(Set<String> itemsToMove,
+ DropTargetEvent event) {
+ tableViewer.add(itemsToMove.toArray(new String[0]));
+ tableViewer.getTable().setFocus();
+ tableViewer.setSelection(new StructuredSelection(itemsToMove
+ .toArray(new String[0])), true);
+ }
+
+ protected void handleMiddleInsertFromTree(Set<String> itemsToMove,
+ DropTargetEvent event) {
+ String[] selectedItems = itemsToMove.toArray(new String[0]);
+ TableItem item = (TableItem) event.item;
+ Point pt = Display.getCurrent().map(null, tableViewer.getTable(),
+ event.x, event.y);
+ Rectangle bounds = item.getBounds();
+ int itemIndex = getItemIndex(item);
+ if (pt.y < bounds.y + bounds.height / 2) {
+ for (int i = 0; i < selectedItems.length; i++) {
+ itemIndex = getItemIndex(item);
+ TableItem tableItem = new TableItem(tableViewer.getTable(),
+ tableViewer.getTable().getStyle(), itemIndex);
+ tableItem.setData(selectedItems[i]);
+ }
+ tableViewer.refresh();
+ tableViewer.setSelection(new StructuredSelection(selectedItems),
+ true);
+ } else if (pt.y >= bounds.y + bounds.height / 2) {
+ for (int i = 0; i < selectedItems.length; i++) {
+ itemIndex = getItemIndex(item);
+ itemIndex = itemIndex + i + 1;
+ if (itemIndex > tableViewer.getTable().getItemCount()) {
+ itemIndex = tableViewer.getTable().getItemCount();
+ }
+ TableItem tableItem = new TableItem(tableViewer.getTable(),
+ tableViewer.getTable().getStyle(), itemIndex);
+ tableItem.setData(selectedItems[i]);
+ }
+ tableViewer.refresh();
+ tableViewer.setSelection(new StructuredSelection(selectedItems),
+ true);
+ }
+ }
+
+ @Override
+ public void dragOver(DropTargetEvent event) {
+ event.feedback = DND.FEEDBACK_SCROLL;
+ if (event.item != null) {
+ TableItem item = (TableItem) event.item;
+ Point pt = Display.getCurrent().map(null, tableViewer.getTable(),
+ event.x, event.y);
+ Rectangle bounds = item.getBounds();
+ if (pt.y < bounds.y + bounds.height / 3) {
+ event.feedback |= DND.FEEDBACK_INSERT_BEFORE;
+ } else if (pt.y > bounds.y + 2 * bounds.height / 3) {
+ event.feedback |= DND.FEEDBACK_INSERT_AFTER;
+ } else {
+ event.feedback |= DND.FEEDBACK_SELECT;
+ }
+ }
+ }
+
+ protected void handleTableSelectionMove(DropTargetEvent event) {
+ if (event.item == null) {
+ handleTableEndInsert(event);
+ } else {
+ handleTableMiddleInsert(event);
+ }
+ }
+
+ private int getItemIndex(TableItem item) {
+ TableItem[] tableItems = tableViewer.getTable().getItems();
+ for (int i = 0; i < tableItems.length; i++) {
+ if (item.getData().equals(tableItems[i].getData())) {
+ return i;
+ }
+ }
+ return 0;
+ }
+
+ protected void handleTableEndInsert(DropTargetEvent event) {
+ List<String> selectedCSSNames = getSelectedItems();
+ CSSSelectionEventManager.getInstance().setHandleSelection(false);
+ tableViewer.remove(selectedCSSNames.toArray(new String[0]));
+ tableViewer.add(selectedCSSNames.toArray(new String[0]));
+ tableViewer.setSelection(new StructuredSelection(selectedCSSNames),
+ true);
+ }
+
+ protected void handleTableMiddleInsert(DropTargetEvent event) {
+ TableItem item = (TableItem) event.item;
+ Point pt = Display.getCurrent().map(null, tableViewer.getTable(),
+ event.x, event.y);
+ Rectangle bounds = item.getBounds();
+ int itemIndex = getItemIndex(item);
+ List<String> selectedItems = getSelectedItems();
+ if (selectedItems.contains(item.getData().toString())) {
+ return;
+ }
+ if (pt.y < bounds.y + bounds.height / 3) {
+ for (int i = 0; i < selectedItems.size(); i++) {
+ CSSSelectionEventManager.getInstance().setHandleSelection(false);
+ tableViewer.remove(selectedItems.get(i));
+ itemIndex = getItemIndex(item);
+ TableItem tableItem = new TableItem(tableViewer.getTable(),
+ tableViewer.getTable().getStyle(), itemIndex);
+ tableItem.setData(selectedItems.get(i));
+ }
+ tableViewer.refresh();
+ tableViewer.setSelection(new StructuredSelection(selectedItems),
+ true);
+ } else if (pt.y > bounds.y + 2 * bounds.height / 3) {
+ for (int i = 0; i < selectedItems.size(); i++) {
+ CSSSelectionEventManager.getInstance().setHandleSelection(false);
+ tableViewer.remove(selectedItems.get(i));
+ itemIndex = getItemIndex(item);
+ itemIndex = itemIndex + i + 1;
+ if (itemIndex > tableViewer.getTable().getItemCount()) {
+ itemIndex = tableViewer.getTable().getItemCount();
+ }
+ TableItem tableItem = new TableItem(tableViewer.getTable(),
+ tableViewer.getTable().getStyle(), itemIndex);
+ tableItem.setData(selectedItems.get(i));
+ }
+ tableViewer.refresh();
+ tableViewer.setSelection(new StructuredSelection(selectedItems),
+ true);
+ }
+ }
+
+ private List<String> getSelectedItems() {
+ List<String> selectedNamesList = new ArrayList<String>(0);
+ TableItem[] selectedItems = tableViewer.getTable().getSelection();
+ if (selectedItems == null) {
+ return selectedNamesList;
+ }
+ for (int i = 0; i < selectedItems.length; i++) {
+ selectedNamesList.add(selectedItems[i].getData().toString());
+ }
+ return selectedNamesList;
+ }
+
+}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTreeDragAdapter.java
(from rev 21000,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTreeDragListener.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTreeDragAdapter.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTreeDragAdapter.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.jsp.outline.cssdialog.cssselector.dnd;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.CSSSelectorPartComposite;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSContainer;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSRuleContainer;
+import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSStyleSheetContainer;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSTreeNode;
+import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.viewers.CSSSelectorTreeViewer;
+import org.w3c.dom.css.CSSRule;
+
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
+@SuppressWarnings("unused")
+public class CSSTreeDragAdapter implements DragSourceListener {
+
+ private Table table;
+ private Tree tree;
+ private CSSSelectorPartComposite parent;
+ private TreeViewer treeViewer;
+ private TableViewer tableViewer;
+
+ public CSSTreeDragAdapter(CSSSelectorPartComposite parent,
+ TreeViewer treeViewer, TableViewer tableViewer) {
+ this.table = tableViewer.getTable();
+ this.tree = treeViewer.getTree();
+ this.treeViewer = treeViewer;
+ this.tableViewer = tableViewer;
+ this.parent = parent;
+ }
+
+ public void dragStart(DragSourceEvent event) {
+ event.doit = tree.getSelectionCount() > 0;
+ }
+
+ public void dragSetData(DragSourceEvent event) {
+ List<String> selectedItems = new ArrayList<String>(0);
+ TreeItem[] selectedTreeItems = tree.getSelection();
+ if (selectedTreeItems != null) {
+ for (int i = 0; i < selectedTreeItems.length; i++) {
+ selectedItems.add(selectedTreeItems[i].getData().toString());
+ }
+ }
+
+ event.data = CSSSelectorTreeViewer.CSS_SELECTOR_TREE_VIWER_ID;
+ }
+
+ public void dragFinished(DragSourceEvent event) {
+ if (event.detail == DND.DROP_MOVE) {
+ Set<CSSTreeNode> itemsToMove = new LinkedHashSet<CSSTreeNode>(0);
+ TreeItem[] selectedItems = treeViewer.getTree().getSelection();
+ if (selectedItems != null && selectedItems.length > 0) {
+ for (int i = 0; i < selectedItems.length; i++) {
+ TreeItem item = selectedItems[i];
+ CSSContainer container = ((CSSTreeNode) item.getData())
+ .getCSSContainer();
+ CSSTreeNode treeNode = (CSSTreeNode) item.getData();
+ if ((container instanceof CSSStyleSheetContainer)) {
+ List<CSSTreeNode> children = treeNode.getChildren();
+ for (int j = 0; j < children.size(); j++) {
+ itemsToMove.add(children.get(j));
+ }
+ } else if (container instanceof CSSRuleContainer) {
+ itemsToMove.add(treeNode);
+ }
+ }
+ for (Iterator<CSSTreeNode> iterator = itemsToMove.iterator(); iterator
+ .hasNext();) {
+ CSSTreeNode cssTreeNode = (CSSTreeNode) iterator.next();
+ tableViewer.add(cssTreeNode.toString());
+ }
+ parent.updateStyles();
+ }
+ }
+ }
+
+}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTreeDragListener.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTreeDragListener.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/dnd/CSSTreeDragListener.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2010 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.jsp.outline.cssdialog.cssselector.dnd;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.CSSSelectorPartComposite;
-import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSContainer;
-import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSRuleContainer;
-import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSTreeNode;
-import
org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.viewers.CSSSelectorTreeViewer;
-import org.w3c.dom.css.CSSRule;
-
-/**
- *
- * @author yzhishko
- *
- */
-
-@SuppressWarnings("unused")
-public class CSSTreeDragListener implements DragSourceListener {
-
- private Table table;
- private Tree tree;
- private CSSSelectorPartComposite parent;
- private TreeViewer treeViewer;
- private TableViewer tableViewer;
-
- public CSSTreeDragListener(CSSSelectorPartComposite parent,
- TreeViewer treeViewer, TableViewer tableViewer) {
- this.table = tableViewer.getTable();
- this.tree = treeViewer.getTree();
- this.treeViewer = treeViewer;
- this.tableViewer = tableViewer;
- this.parent = parent;
- }
-
- public void dragStart(DragSourceEvent event) {
- event.doit = tree.getSelectionCount() > 0;
- }
-
- public void dragSetData(DragSourceEvent event) {
- List<String> selectedItems = new ArrayList<String>(0);
- TreeItem[] selectedTreeItems = tree.getSelection();
- if (selectedTreeItems != null) {
- for (int i = 0; i < selectedTreeItems.length; i++) {
- selectedItems.add(selectedTreeItems[i].getData().toString());
- }
- }
-
- event.data = CSSSelectorTreeViewer.CSS_SELECTOR_TREE_VIWER_ID;
- }
-
- public void dragFinished(DragSourceEvent event) {
- if (event.detail == DND.DROP_MOVE) {
- List<String> selectedItems = new ArrayList<String>(0);
- TreeItem[] selectedTreeItems = tree.getSelection();
- if (selectedTreeItems != null) {
- for (int i = 0; i < selectedTreeItems.length; i++) {
- if (((CSSTreeNode) selectedTreeItems[i].getData())
- .getCSSContainer() instanceof CSSRuleContainer) {
- selectedItems.add(selectedTreeItems[i].getData()
- .toString());
- }
- }
- }
- for (int i = 0; i < selectedItems.size(); i++) {
- tableViewer.add(selectedItems.get(i));
- }
- parent.updateStyles();
- }
- }
-
-}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSContainer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSContainer.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSContainer.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -14,13 +14,13 @@
/**
*
* @author yzhishko
- *
+ *
*/
public abstract class CSSContainer {
private String styleSheetPath;
-
+
public CSSContainer(String styleSheetPath) {
this.setStyleSheetPath(styleSheetPath);
}
@@ -32,7 +32,7 @@
public String getStyleSheetPath() {
return styleSheetPath;
}
-
+
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -41,7 +41,7 @@
if (!(obj instanceof CSSContainer)) {
return false;
}
- return styleSheetPath.equals(((CSSContainer)obj).getStyleSheetPath());
+ return styleSheetPath.equals(((CSSContainer) obj).getStyleSheetPath());
}
-
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSJSPRecognizer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSJSPRecognizer.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSJSPRecognizer.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -33,14 +33,14 @@
/**
*
* @author yzhishko
- *
+ *
*/
@SuppressWarnings("restriction")
public class CSSJSPRecognizer {
private JSPMultiPageEditor jspMultiPageEditor;
-
+
public static final int OK = 0;
public static final int VOID_RESULT = 1;
private List<CSSStyleSheet> styleSheets;
@@ -51,7 +51,7 @@
public CSSJSPRecognizer(JSPMultiPageEditor jspMultiPageEditor) {
this.jspMultiPageEditor = jspMultiPageEditor;
}
-
+
private List<CSSRuleList> extractCSSRulesLists() {
ICSSContainerSupport cssContainerSupport = null;
ELContext context = PageContextFactory.createPageContext(getFile());
@@ -109,9 +109,8 @@
}
return cssRules.toArray(new CSSRule[0]);
}
-
- public Map<String, Map<String, String>> getCSSStyleMap(
- CSSRule[] cssRules) {
+
+ public Map<String, Map<String, String>> getCSSStyleMap(CSSRule[] cssRules)
{
if (cssRules == null) {
return null;
}
@@ -120,26 +119,32 @@
for (int i = 0; i < cssRules.length; i++) {
ICSSStyleRule styleRule = (ICSSStyleRule) cssRules[i];
String styleClassSelector = styleRule.getSelectorText();
- String[] selectors = CSSSelectorUtils.parseSelectorName(styleClassSelector);
+ String[] selectors = CSSSelectorUtils
+ .parseSelectorName(styleClassSelector);
for (int j = 0; j < selectors.length; j++) {
String styleClassName = selectors[j];
ICSSNodeList cssNodeList = styleRule.getChildNodes();
if (cssNodeList == null) {
continue;
}
- Map<String, String> attrsMap = new LinkedHashMap<String, String>(0);
+ Map<String, String> attrsMap = new LinkedHashMap<String, String>(
+ 0);
for (int k = 0; k < cssNodeList.getLength(); k++) {
- ICSSStyleDeclaration styleDeclaration = (ICSSStyleDeclaration) cssNodeList.item(k);
+ ICSSStyleDeclaration styleDeclaration = (ICSSStyleDeclaration) cssNodeList
+ .item(k);
ICSSNodeList attrsList = styleDeclaration.getChildNodes();
if (attrsList == null) {
continue;
}
for (int l = 0; l < attrsList.getLength(); l++) {
- ICSSStyleDeclItem styleItem = (ICSSStyleDeclItem) attrsList.item(l);
- attrsMap.put(styleItem.getPropertyName(), styleItem.getCSSValueText());
+ ICSSStyleDeclItem styleItem = (ICSSStyleDeclItem) attrsList
+ .item(l);
+ attrsMap.put(styleItem.getPropertyName(), styleItem
+ .getCSSValueText());
}
}
- Map<String, String> attrsForCSSStyle = styleMap.get(styleClassName);
+ Map<String, String> attrsForCSSStyle = styleMap
+ .get(styleClassName);
if (attrsForCSSStyle == null) {
styleMap.put(styleClassName, attrsMap);
} else {
@@ -151,23 +156,25 @@
}
return styleMap;
}
-
- public CSSSelectorTreeModel getCssStyleClassTreeModel(CSSStyleSheetDescriptor[]
cssSheets){
+
+ public CSSSelectorTreeModel getCssStyleClassTreeModel(
+ CSSStyleSheetDescriptor[] cssSheets) {
if (cssSheets != null) {
return new CSSSelectorTreeModel(cssSheets);
}
return null;
}
-
- public CSSSelectorTreeModel getCssStyleClassTreeModel(){
- return getCssStyleClassTreeModel(styleSheetDescriptors.toArray(new
CSSStyleSheetDescriptor[0]));
+
+ public CSSSelectorTreeModel getCssStyleClassTreeModel() {
+ return getCssStyleClassTreeModel(styleSheetDescriptors
+ .toArray(new CSSStyleSheetDescriptor[0]));
}
-
+
public Map<String, Map<String, String>> getCSSStyleMap() {
return getCSSStyleMap(this.cssRules);
}
-
- public int parseCSS(){
+
+ public int parseCSS() {
this.cssRuleLists = extractCSSRulesLists();
this.cssRules = extractCSSRules(this.cssRuleLists);
if (cssRules != null && cssRules.length != 0) {
@@ -175,13 +182,13 @@
}
return VOID_RESULT;
}
-
+
public CSSStyleSheet[] getStyleSheets() {
return styleSheets.toArray(new CSSStyleSheet[0]);
}
-
+
public CSSRule[] getCssRules() {
return cssRules;
}
-
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSRuleContainer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSRuleContainer.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSRuleContainer.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -16,7 +16,7 @@
/**
*
* @author yzhishko
- *
+ *
*/
public class CSSRuleContainer extends CSSContainer {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorTableModel.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorTableModel.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorTableModel.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -16,13 +16,13 @@
/**
*
* @author yzhishko
- *
+ *
*/
public class CSSSelectorTableModel {
private List<String> containerList = new ArrayList<String>(0);
-
+
public List<String> getContainerList() {
return containerList;
}
@@ -30,15 +30,13 @@
public CSSSelectorTableModel(String... classNames) {
initModel(classNames);
}
-
- private void initModel(String... classNames){
+
+ private void initModel(String... classNames) {
if (classNames != null) {
for (int i = 0; i < classNames.length; i++) {
containerList.add(classNames[i]);
}
}
}
-
-
-
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorTreeModel.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorTreeModel.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorTreeModel.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -53,8 +53,8 @@
.getSelectorText());
for (int k = 0; k < selectors.length; k++) {
CSSTreeNode ruleNode = new CSSTreeNode(selectors[k]);
- ruleNode.setCSSContainer(new CSSRuleContainer(selectors[k], cssRule,
- cssStyleSheets[i].source));
+ ruleNode.setCSSContainer(new CSSRuleContainer(selectors[k],
+ cssRule, cssStyleSheets[i].source));
ruleNode.setStyleSheetSource(cssStyleSheets[i].source);
parentSheet.addChild(ruleNode);
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorUtils.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorUtils.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSSelectorUtils.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -11,34 +11,52 @@
package org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model;
+import java.io.IOException;
+import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
+import org.eclipse.wst.css.core.internal.parser.CSSTokenizer;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
/**
*
* @author yzhishko
- *
+ *
*/
+@SuppressWarnings("restriction")
public class CSSSelectorUtils {
- private static String filterName(String className){
+ private static String filterName(String className) {
className = className.trim();
if (className.indexOf(' ') > -1) {
return null;
}
- if (className.indexOf('.')==className.lastIndexOf('.')) {
+ if (className.indexOf('.') == className.lastIndexOf('.')) {
if (className.indexOf('.') == 0) {
- return className.substring(className.indexOf('.')+1);
+ CSSTokenizer cssTokenizer = new CSSTokenizer(new StringReader(
+ className + "{}")); //$NON-NLS-1$
+ try {
+ while (!cssTokenizer.isEOF()) {
+ String token = cssTokenizer.primGetNextToken();
+ if ("undefined".equalsIgnoreCase(token)) { //$NON-NLS-1$
+ return null;
+ }
+ }
+ } catch (IOException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ return className.substring(className.indexOf('.') + 1);
}
}
return null;
}
-
- public static String[] parseSelectorName(String selectorText){
+
+ public static String[] parseSelectorName(String selectorText) {
List<String> selectors = new ArrayList<String>(0);
- StringTokenizer tokenizer = new StringTokenizer(selectorText, ",", false);
//$NON-NLS-1$
+ StringTokenizer tokenizer = new StringTokenizer(selectorText,
+ ",", false); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
String selectorName = tokenizer.nextToken();
selectorName = filterName(selectorName);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSStyleSheetContainer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSStyleSheetContainer.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSStyleSheetContainer.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -16,7 +16,7 @@
/**
*
* @author yzhishko
- *
+ *
*/
public class CSSStyleSheetContainer extends CSSContainer {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSTreeNode.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSTreeNode.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/model/CSSTreeNode.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -17,7 +17,7 @@
/**
*
* @author yzhishko
- *
+ *
*/
public class CSSTreeNode {
@@ -61,12 +61,13 @@
public CSSContainer getCSSContainer() {
return cssResource;
}
-
- public void setStyleSheetSource(String source){
+
+ public void setStyleSheetSource(String source) {
styleSheetSource = source;
}
-
- public String getStyleSheetSource(){
+
+ public String getStyleSheetSource() {
return styleSheetSource;
}
+
}
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/CSSSelectionEventManager.java
(from rev 21000,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/CSSSelectorEventManager.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/CSSSelectionEventManager.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/CSSSelectionEventManager.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.jsp.outline.cssdialog.cssselector.selection;
+
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSSelectorTreeModel;
+
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
+public class CSSSelectionEventManager {
+
+ private static CSSSelectionEventManager instance = new CSSSelectionEventManager();
+ private boolean handleSelection = true;
+
+ private CSSSelectionEventManager() {
+
+ }
+
+ public static CSSSelectionEventManager getInstance() {
+ return instance;
+ }
+
+ public CSSTreeSelectionChangedEvent createTreeSelectionChangedEvent(
+ SelectionChangedEvent event, CSSSelectorTreeModel model) {
+ return new CSSTreeSelectionChangedEvent(event.getSelectionProvider(),
+ event.getSelection(), model);
+ }
+
+ public CSSTableSelectionChangedEvent createTableSelectionChangedEvent(
+ SelectionChangedEvent event, CSSSelectorTreeModel model) {
+ return new CSSTableSelectionChangedEvent(event.getSelectionProvider(),
+ event.getSelection(), model);
+ }
+
+ public void setHandleSelection(boolean handleSelection) {
+ this.handleSelection = handleSelection;
+ }
+
+ public boolean isHandleSelection() {
+ return handleSelection;
+ }
+
+}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/CSSSelectorEventManager.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/CSSSelectorEventManager.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/CSSSelectorEventManager.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2010 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.jsp.outline.cssdialog.cssselector.selection;
-
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.model.CSSSelectorTreeModel;
-
-/**
- *
- * @author yzhishko
- *
- */
-
-public class CSSSelectorEventManager {
-
- private static CSSSelectorEventManager instance = new CSSSelectorEventManager();
-
- private CSSSelectorEventManager() {
-
- }
-
- public static CSSSelectorEventManager getInstance() {
- return instance;
- }
-
- public CSSTreeSelectionChangedEvent createTreeSelectionChangedEvent(
- SelectionChangedEvent event, CSSSelectorTreeModel model) {
- return new CSSTreeSelectionChangedEvent(event.getSelectionProvider(),
- event.getSelection(), model);
- }
-
- public CSSTableSelectionChangedEvent createTableSelectionChangedEvent(
- SelectionChangedEvent event, CSSSelectorTreeModel model) {
- return new CSSTableSelectionChangedEvent(event.getSelectionProvider(),
- event.getSelection(), model);
- }
-
-}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/ICSSClassSelectionChangedListener.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/ICSSClassSelectionChangedListener.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/selection/ICSSClassSelectionChangedListener.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -14,11 +14,11 @@
/**
*
* @author yzhishko
- *
+ *
*/
public interface ICSSClassSelectionChangedListener {
void classSelectionChanged(CSSClassSelectionChangedEvent event);
-
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorFilter.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorFilter.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorFilter.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -20,31 +20,31 @@
/**
*
* @author yzhishko
- *
+ *
*/
-public class CSSSelectorFilter extends ViewerFilter{
+public class CSSSelectorFilter extends ViewerFilter {
private Set<String> filterNames = new HashSet<String>(0);
-
+
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (filterNames.contains(((CSSTreeNode)element).toString())) {
+ if (filterNames.contains(((CSSTreeNode) element).toString())) {
return false;
}
return true;
}
-
- public void removeFilterName(String name){
+
+ public void removeFilterName(String name) {
filterNames.remove(name);
}
-
- public void addFilterName(String name){
+
+ public void addFilterName(String name) {
filterNames.add(name);
}
-
- public void removeAllFilters(){
+
+ public void removeAllFilters() {
filterNames.clear();
}
-
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTableContentProvider.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTableContentProvider.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTableContentProvider.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -19,22 +19,22 @@
/**
*
* @author yzhishko
- *
+ *
*/
-public class CSSSelectorTableContentProvider implements IListContentProvider{
+public class CSSSelectorTableContentProvider implements IListContentProvider {
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement) {
- return ((List<String>)inputElement).toArray();
+ return ((List<String>) inputElement).toArray();
}
public void dispose() {
-
+
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
+
}
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTableViewer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTableViewer.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTableViewer.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -13,10 +13,10 @@
import java.util.ArrayList;
import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableItem;
@@ -27,36 +27,44 @@
/**
*
* @author yzhishko
- *
+ *
*/
-public class CSSSelectorTableViewer extends TableViewer{
+public class CSSSelectorTableViewer extends TableViewer {
public final static String CSS_SELECTOR_TABLE_VIWER_ID =
"css_selector_table_viwer"; //$NON-NLS-1$
- private final static ImageDescriptor CSS_STYLE_CLASS_DESCR =
JspEditorPlugin.getImageDescriptor(Constants.IMAGE_STYLE_CLASS_LOCATION);
+ private Image CSS_STYLE_CLASS_IMAGE = JspEditorPlugin.getImageDescriptor(
+ Constants.IMAGE_STYLE_CLASS_LOCATION).createImage();
private CSSSelectorTableModel model;
-
+
public CSSSelectorTableViewer(Composite parent, int style) {
super(parent, style);
setContentProvider(new CSSSelectorTableContentProvider());
- setLabelProvider(new LabelProvider(){
+ setLabelProvider(new LabelProvider() {
@Override
public Image getImage(Object element) {
- return CSS_STYLE_CLASS_DESCR.createImage();
+ return CSS_STYLE_CLASS_IMAGE;
}
});
+ getTable().addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ CSS_STYLE_CLASS_IMAGE.dispose();
+ CSS_STYLE_CLASS_IMAGE = null;
+ }
+ });
}
-
- public void setModel(CSSSelectorTableModel model){
+
+ public void setModel(CSSSelectorTableModel model) {
setInput(model.getContainerList());
this.model = model;
}
-
- public CSSSelectorTableModel getModel(){
+
+ public CSSSelectorTableModel getModel() {
return model;
}
-
+
@Override
public void add(Object element) {
if (element != null) {
@@ -66,7 +74,7 @@
}
super.add(element);
}
-
+
@Override
public void add(Object[] elements) {
List<Object> objects = new ArrayList<Object>(0);
@@ -79,8 +87,8 @@
}
super.add(objects.toArray());
}
-
- private boolean isContain(Object element){
+
+ private boolean isContain(Object element) {
TableItem[] items = getTable().getItems();
if (items != null) {
for (int i = 0; i < items.length; i++) {
@@ -91,5 +99,20 @@
}
return false;
}
-
+
+ @Override
+ public void refresh() {
+ if (model != null) {
+ model.getContainerList().clear();
+ TableItem[] tableItems = getTable().getItems();
+ if (tableItems != null) {
+ for (int i = 0; i < tableItems.length; i++) {
+ model.getContainerList().add(
+ tableItems[i].getData().toString());
+ }
+ }
+ }
+ super.refresh();
+ }
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeContentProvider.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeContentProvider.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeContentProvider.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -18,25 +18,25 @@
/**
*
* @author yzhishko
- *
+ *
*/
public class CSSSelectorTreeContentProvider implements ITreeContentProvider {
public Object[] getChildren(Object parentElement) {
- return ((CSSTreeNode)parentElement).getChildren().toArray();
+ return ((CSSTreeNode) parentElement).getChildren().toArray();
}
public Object getParent(Object element) {
- return ((CSSTreeNode)element).getParent();
+ return ((CSSTreeNode) element).getParent();
}
public boolean hasChildren(Object element) {
- return ((CSSTreeNode)element).hasChildren();
+ return ((CSSTreeNode) element).hasChildren();
}
public Object[] getElements(Object inputElement) {
- return ((CSSTreeNode)inputElement).getChildren().toArray();
+ return ((CSSTreeNode) inputElement).getChildren().toArray();
}
public void dispose() {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeLabelProvider.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeLabelProvider.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeLabelProvider.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -11,7 +11,6 @@
package org.jboss.tools.jst.jsp.outline.cssdialog.cssselector.viewers;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
@@ -23,23 +22,34 @@
/**
*
* @author yzhishko
- *
+ *
*/
public class CSSSelectorTreeLabelProvider extends LabelProvider {
- private final static ImageDescriptor CSS_STYLE_SHEET_DESCR =
JspEditorPlugin.getImageDescriptor(Constants.IMAGE_STYLE_SHEET_LOCATION);
- private final static ImageDescriptor CSS_STYLE_CLASS_DESCR =
JspEditorPlugin.getImageDescriptor(Constants.IMAGE_STYLE_CLASS_LOCATION);
-
+ private Image CSS_STYLE_SHEET_IMAGE = JspEditorPlugin.getImageDescriptor(
+ Constants.IMAGE_STYLE_SHEET_LOCATION).createImage();
+ private Image CSS_STYLE_CLASS_IMAGE = JspEditorPlugin.getImageDescriptor(
+ Constants.IMAGE_STYLE_CLASS_LOCATION).createImage();
+
@Override
public Image getImage(Object element) {
if (((CSSTreeNode) element).getCSSContainer() instanceof CSSStyleSheetContainer) {
- return CSS_STYLE_SHEET_DESCR.createImage();
+ return CSS_STYLE_SHEET_IMAGE;
}
if (((CSSTreeNode) element).getCSSContainer() instanceof CSSRuleContainer) {
- return CSS_STYLE_CLASS_DESCR.createImage();
+ return CSS_STYLE_CLASS_IMAGE;
}
return super.getImage(element);
}
-
+
+ @Override
+ public void dispose() {
+ CSS_STYLE_CLASS_IMAGE.dispose();
+ CSS_STYLE_SHEET_IMAGE.dispose();
+ CSS_STYLE_CLASS_IMAGE = null;
+ CSS_STYLE_SHEET_IMAGE = null;
+ super.dispose();
+ }
+
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeViewer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeViewer.java 2010-03-26
14:43:50 UTC (rev 21054)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/cssselector/viewers/CSSSelectorTreeViewer.java 2010-03-26
16:23:10 UTC (rev 21055)
@@ -18,28 +18,28 @@
/**
*
* @author yzhishko
- *
+ *
*/
public class CSSSelectorTreeViewer extends TreeViewer {
public final static String CSS_SELECTOR_TREE_VIWER_ID =
"css_selector_tree_viwer"; //$NON-NLS-1$
private CSSSelectorTreeModel model;
-
+
public CSSSelectorTreeViewer(Composite parent, int style) {
super(parent, style);
setContentProvider(new CSSSelectorTreeContentProvider());
setLabelProvider(new CSSSelectorTreeLabelProvider());
}
-
- public void setModel(CSSSelectorTreeModel model){
+
+ public void setModel(CSSSelectorTreeModel model) {
if (model != null) {
setInput(model.getInvisibleRoot());
this.model = model;
}
}
-
- public CSSSelectorTreeModel getModel(){
+
+ public CSSSelectorTreeModel getModel() {
return model;
}