Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-08-21 07:43:07 -0400
committerCamille Letavernier2014-08-21 09:50:25 -0400
commitdbc038b44bcbb890ae256d15eb09eb285512f020 (patch)
tree757e736583eea3ae352ad9ac91a81df7e59b79ff /plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src
parentea48a20561464c3cbb7895d430583669a9f82fcc (diff)
downloadorg.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.tar.gz
org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.tar.xz
org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.zip
[Code style] Apply clean-up and formatter on Main plug-ins
Diffstat (limited to 'plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/Activator.java4
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java96
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java95
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java16
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java6
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java14
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java54
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java106
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/DiagramTypeHelper.java14
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/XtextStylesheetHelper.java44
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java46
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java28
12 files changed, 262 insertions, 261 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/Activator.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/Activator.java
index aac4232ff39..4029bbddf8c 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/Activator.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/Activator.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -59,7 +59,7 @@ public class Activator extends AbstractUIPlugin {
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static Activator getDefault() {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java
index 1129c431c78..a95c96b1579 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleDialog.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012, 2014 CEA LIST and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 392301
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.configuration.handler;
@@ -105,7 +105,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
selectorPreview.setLabel("Selector preview:");
selectorPreview.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
- GridLayout layout = (GridLayout)selectorPreview.getLayout();
+ GridLayout layout = (GridLayout) selectorPreview.getLayout();
layout.marginWidth = 0;
tabFolder = new CTabFolder(parent, SWT.BORDER);
@@ -143,7 +143,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
}
protected void updateButtons() {
- //Resets the error message
+ // Resets the error message
setError(null);
getButton(IDialogConstants.OK_ID).setEnabled(isValid());
getDialogArea().layout();
@@ -152,10 +152,10 @@ public abstract class AbstractStyleDialog extends TrayDialog {
protected boolean isValid() {
boolean result = true;
- //There must be at least one property declaration
+ // There must be at least one property declaration
boolean atLeastOneDeclaration = false;
- for(Boolean value : declarations.values()) {
- if(value) {
+ for (Boolean value : declarations.values()) {
+ if (value) {
atLeastOneDeclaration = true;
break;
}
@@ -163,7 +163,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
result = result && atLeastOneDeclaration;
- if(!atLeastOneDeclaration) {
+ if (!atLeastOneDeclaration) {
setError("There must be at least one property declaration");
}
@@ -171,20 +171,20 @@ public abstract class AbstractStyleDialog extends TrayDialog {
}
protected void setError(String errorMessage) {
- if(errorMessage == null && errorLabel != null) {
+ if (errorMessage == null && errorLabel != null) {
errorLabel.dispose();
errorLabel = null;
return;
}
- if(errorMessage != null) {
- if(errorLabel == null) {
+ if (errorMessage != null) {
+ if (errorLabel == null) {
errorLabel = new CLabel(getDialogArea(), SWT.WRAP);
errorLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
errorLabel.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/error.gif"));
}
- if(errorLabel.getText() != null && !errorLabel.getText().trim().equals("")) {
+ if (errorLabel.getText() != null && !errorLabel.getText().trim().equals("")) {
errorLabel.setText(errorLabel.getText() + "\n" + errorMessage);
} else {
errorLabel.setText(errorMessage);
@@ -212,17 +212,17 @@ public abstract class AbstractStyleDialog extends TrayDialog {
@Override
public String getText(Object element) {
- Boolean value = (Boolean)element;
+ Boolean value = (Boolean) element;
return value ? getDiagramType(contextView.getDiagram()) + " only" : "Any diagram";
}
};
- diagramRestrictionWidget.setProviders(new StaticContentProvider(new Boolean[]{ true, false }), labelProvider);
+ diagramRestrictionWidget.setProviders(new StaticContentProvider(new Boolean[] { true, false }), labelProvider);
diagramRestrictionWidget.setValue(this.diagramRestriction);
diagramRestrictionWidget.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- diagramRestriction = (Boolean)((EnumRadio)editor).getValue();
+ diagramRestriction = (Boolean) ((EnumRadio) editor).getValue();
updateSelectorLabel();
}
});
@@ -234,24 +234,24 @@ public abstract class AbstractStyleDialog extends TrayDialog {
@Override
public String getText(Object element) {
- Boolean value = (Boolean)element;
+ Boolean value = (Boolean) element;
return value ? selectorName + " only" : "Any kind of element";
}
};
- selectorNameWidget.setProviders(new StaticContentProvider(new Boolean[]{ true, false }), labelProvider);
+ selectorNameWidget.setProviders(new StaticContentProvider(new Boolean[] { true, false }), labelProvider);
selectorNameWidget.setValue(this.useSelectorName);
selectorNameWidget.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- useSelectorName = (Boolean)((EnumRadio)editor).getValue();
+ useSelectorName = (Boolean) ((EnumRadio) editor).getValue();
updateSelectorLabel();
}
});
}
protected void createAttributeSelectorsSection(Composite parent) {
- if(conditions.isEmpty()) {
+ if (conditions.isEmpty()) {
return;
}
@@ -259,11 +259,11 @@ public abstract class AbstractStyleDialog extends TrayDialog {
detailLabel.setText("If the following properties are matched:");
detailLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1));
- for(SelectorCondition condition : conditions.keySet()) {
- final Attribute currentCondition = (Attribute)condition;
+ for (SelectorCondition condition : conditions.keySet()) {
+ final Attribute currentCondition = (Attribute) condition;
String attributeLabel = currentCondition.getName();
- if(currentCondition.getValue() != null) {
+ if (currentCondition.getValue() != null) {
attributeLabel += " " + currentCondition.getValue().getOperator() + " " + currentCondition.getValue().getValue();
}
@@ -273,7 +273,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
checkbox.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- conditions.put(currentCondition, ((BooleanCheckbox)editor).getValue());
+ conditions.put(currentCondition, ((BooleanCheckbox) editor).getValue());
updateSelectorLabel();
}
});
@@ -294,7 +294,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
styleNameEditor.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- cssClass = (String)((StringEditor)editor).getValue();
+ cssClass = (String) ((StringEditor) editor).getValue();
updateSelectorLabel();
}
@@ -308,10 +308,10 @@ public abstract class AbstractStyleDialog extends TrayDialog {
declarationsLabel.setText("Select the properties you want to set. Unchecked properties will keep their default value\n (Which might be inherited from another style).");
declarationsLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1));
- for(Declaration declaration : declarations.keySet()) {
- //Separate checkbox and label (Checkbox - Label) - (Checkbox - Label) - (Checkbox - Label)
- //This is required to paint a custom foreground color on non-classic windows Theme
- //Checkboxes do not support foreground color on Windows, except for the Classic theme
+ for (Declaration declaration : declarations.keySet()) {
+ // Separate checkbox and label (Checkbox - Label) - (Checkbox - Label) - (Checkbox - Label)
+ // This is required to paint a custom foreground color on non-classic windows Theme
+ // Checkboxes do not support foreground color on Windows, except for the Classic theme
Composite propertyComposite = new Composite(parent, SWT.NONE);
GridLayout compositeLayout = new GridLayout(2, false);
compositeLayout.marginWidth = 0;
@@ -348,7 +348,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
checkbox.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- boolean value = ((BooleanCheckbox)editor).getValue();
+ boolean value = ((BooleanCheckbox) editor).getValue();
declarations.put(currentDeclaration, value);
updateButtons();
}
@@ -360,27 +360,27 @@ public abstract class AbstractStyleDialog extends TrayDialog {
protected Color[] getColors(Expression expression) {
Term term = expression.getTerms();
- if(term instanceof HexColor) {
- HexColor hexColor = (HexColor)term;
+ if (term instanceof HexColor) {
+ HexColor hexColor = (HexColor) term;
return getColors(hexColor);
}
- for(Subterm subterm : expression.getSubterms()) {
- if(subterm.getTerm() instanceof HexColor) {
- return getColors((HexColor)subterm.getTerm());
+ for (Subterm subterm : expression.getSubterms()) {
+ if (subterm.getTerm() instanceof HexColor) {
+ return getColors((HexColor) subterm.getTerm());
}
}
- return new Color[]{ Display.getDefault().getSystemColor(SWT.COLOR_WHITE), Display.getDefault().getSystemColor(SWT.COLOR_BLACK), };
+ return new Color[] { Display.getDefault().getSystemColor(SWT.COLOR_WHITE), Display.getDefault().getSystemColor(SWT.COLOR_BLACK), };
}
protected Color[] getColors(HexColor hexColor) {
- Color[] colors = new Color[]{ Display.getDefault().getSystemColor(SWT.COLOR_WHITE), Display.getDefault().getSystemColor(SWT.COLOR_BLACK), };
+ Color[] colors = new Color[] { Display.getDefault().getSystemColor(SWT.COLOR_WHITE), Display.getDefault().getSystemColor(SWT.COLOR_BLACK), };
Color color = getColor(hexColor);
colors[0] = color;
- if(getLightness(color) < 130) {
+ if (getLightness(color) < 130) {
colors[1] = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
}
@@ -388,7 +388,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
}
private int getLightness(Color color) {
- //Computes the lightness of the color
+ // Computes the lightness of the color
int M = Math.max(color.getGreen(), Math.max(color.getRed(), color.getBlue()));
int m = Math.min(color.getGreen(), Math.min(color.getRed(), color.getBlue()));
int L = (M + m) / 2;
@@ -402,19 +402,19 @@ public abstract class AbstractStyleDialog extends TrayDialog {
}
public String getCSSClass() {
- if(cssClass != null) {
+ if (cssClass != null) {
return cssClass.trim().equals("") ? null : cssClass.trim();
}
return null;
}
protected String getLabel(Expression expression) {
- if(expression == null) {
+ if (expression == null) {
return "";
}
String label = getLabel(expression.getTerms());
- for(Subterm subTerm : expression.getSubterms()) {
- if(subTerm.getOperator() != null) {
+ for (Subterm subTerm : expression.getSubterms()) {
+ if (subTerm.getOperator() != null) {
label += subTerm.getOperator();
}
label += " " + getLabel(subTerm.getTerm());
@@ -443,7 +443,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
@Override
public String caseNumber(Number term) {
String label = "";
- if(term.getOp() != null) {
+ if (term.getOp() != null) {
label += term.getOp().getOperator();
}
label += term.getValue();
@@ -455,14 +455,14 @@ public abstract class AbstractStyleDialog extends TrayDialog {
protected void updateSelectorLabel() {
String selectorText = "";
- if(diagramRestriction) {
+ if (diagramRestriction) {
selectorText += getDiagramType(contextView.getDiagram()) + " ";
}
selectorText += useSelectorName ? selectorName : "*";
- for(Entry<Attribute, Boolean> selectorEntry : conditions.entrySet()) {
- if(selectorEntry.getValue()) {
+ for (Entry<Attribute, Boolean> selectorEntry : conditions.entrySet()) {
+ if (selectorEntry.getValue()) {
Attribute condition = selectorEntry.getKey();
Attribute attribute = condition;
AttributeValue value = attribute.getValue();
@@ -470,7 +470,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
}
}
- if(cssClass != null && !"".equals(cssClass)) {
+ if (cssClass != null && !"".equals(cssClass)) {
selectorText += "." + cssClass;
}
@@ -485,7 +485,7 @@ public abstract class AbstractStyleDialog extends TrayDialog {
@Override
public Composite getDialogArea() {
- return (Composite)super.getDialogArea();
+ return (Composite) super.getDialogArea();
}
public boolean useSelectorName() {
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java
index df0e7877f44..7579b3b51ee 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/AbstractStyleHandler.java
@@ -39,6 +39,7 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForHandlers;
@@ -70,7 +71,7 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
ISelection selection;
try {
selection = ServiceUtilsForHandlers.getInstance().getNestedActiveIEditorPart(event).getSite().getSelectionProvider().getSelection();
- if(selection.isEmpty()) {
+ if (selection.isEmpty()) {
return null;
}
} catch (ServiceException ex) {
@@ -78,22 +79,22 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
return null;
}
- if(!(selection instanceof IStructuredSelection)) {
+ if (!(selection instanceof IStructuredSelection)) {
return null;
}
- IStructuredSelection sSelection = (IStructuredSelection)selection;
+ IStructuredSelection sSelection = (IStructuredSelection) selection;
Object element = sSelection.getFirstElement();
View view = NotationHelper.findView(element);
- if(view == null) {
+ if (view == null) {
Activator.log.warn("Cannot create a Style from the selected element ; the element is not a View");
return null;
}
- Shell parentShell = ((Event)event.getTrigger()).widget.getDisplay().getActiveShell();
+ Shell parentShell = ((Event) event.getTrigger()).widget.getDisplay().getActiveShell();
- if(view.getElement() == null || view instanceof Diagram) {
+ if (view.getElement() == null || view instanceof Diagram) {
MessageDialog.open(MessageDialog.WARNING, parentShell, "Style error", "The selected element's style cannot be exported", SWT.NONE);
return null;
}
@@ -105,20 +106,20 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
AbstractStyleDialog dialog = createStyleDialog(parentShell, declarations, conditions, selectorName, view);
- if(dialog.open() != Dialog.OK) {
+ if (dialog.open() != Window.OK) {
return null;
}
Ruleset ruleset = getRuleset(dialog);
SimpleSelector selector = CssFactory.eINSTANCE.createSimpleSelector();
- if(dialog.useSelectorName()) {
+ if (dialog.useSelectorName()) {
selector.setElementName(selectorName);
} else {
selector.setElementName("*"); //$NON-NLS-1$
}
- if(dialog.getDiagramRestriction()) {
+ if (dialog.getDiagramRestriction()) {
String diagramType = getDiagramType(view.getDiagram());
CompositeSelector compositeSelector = CssFactory.eINSTANCE.createCompositeSelector();
compositeSelector.setRight(selector);
@@ -132,34 +133,34 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
ruleset.getSelectors().add(selector);
}
- if(dialog.getCSSClass() != null) {
+ if (dialog.getCSSClass() != null) {
String cssClass = dialog.getCSSClass();
org.eclipse.papyrus.infra.gmfdiag.css.Class classCondition = CssFactory.eINSTANCE.createClass();
classCondition.setClass(cssClass);
selector.getCondition().add(classCondition);
}
- for(SelectorCondition condition : conditions.keySet()) {
- if(conditions.get(condition)) {
+ for (SelectorCondition condition : conditions.keySet()) {
+ if (conditions.get(condition)) {
selector.getCondition().add(condition);
}
}
- for(Declaration declaration : declarations.keySet()) {
- if(declarations.get(declaration)) {
+ for (Declaration declaration : declarations.keySet()) {
+ if (declarations.get(declaration)) {
ruleset.getProperties().add(declaration);
}
}
Stylesheet xtextStylesheet = getStyleSheet(dialog, view);
- if(xtextStylesheet == null) {
+ if (xtextStylesheet == null) {
return null;
}
Resource resource = xtextStylesheet.eResource();
- if(!xtextStylesheet.getContents().contains(ruleset)) {
+ if (!xtextStylesheet.getContents().contains(ruleset)) {
xtextStylesheet.getContents().add(ruleset);
}
@@ -188,17 +189,17 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
protected Map<Declaration, Boolean> handleStyles(View view) {
Map<Declaration, Boolean> declarations = new LinkedHashMap<Declaration, Boolean>();
- for(Object styleObject : view.getStyles()) {
- Style style = (Style)styleObject;
+ for (Object styleObject : view.getStyles()) {
+ Style style = (Style) styleObject;
declarations.putAll(handleStyle(style));
}
- if(view instanceof Style) {
- declarations.putAll(handleStyle((Style)view));
+ if (view instanceof Style) {
+ declarations.putAll(handleStyle((Style) view));
}
- if(view instanceof CustomStyle) {
- declarations.putAll(handleCustomStyle((CustomStyle)view, view));
+ if (view instanceof CustomStyle) {
+ declarations.putAll(handleCustomStyle((CustomStyle) view, view));
}
return declarations;
@@ -209,8 +210,8 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
EObject semanticElement = view.getElement();
- for(EStructuralFeature feature : semanticElement.eClass().getEAllStructuralFeatures()) {
- if(isBoolean(feature) || isInteger(feature) || feature.getEType() instanceof EEnum) {
+ for (EStructuralFeature feature : semanticElement.eClass().getEAllStructuralFeatures()) {
+ if (isBoolean(feature) || isInteger(feature) || feature.getEType() instanceof EEnum) {
Attribute attributeCondition = CssFactory.eINSTANCE.createAttribute();
attributeCondition.setName(feature.getName());
@@ -229,12 +230,12 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
}
protected boolean isBoolean(EStructuralFeature feature) {
- if(feature.getEType() == EcorePackage.eINSTANCE.getEBoolean() || feature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
+ if (feature.getEType() == EcorePackage.eINSTANCE.getEBoolean() || feature.getEType() == EcorePackage.eINSTANCE.getEBooleanObject()) {
return true;
}
- if(feature.getEType() instanceof EDataType) {
- EDataType datatype = (EDataType)feature.getEType();
+ if (feature.getEType() instanceof EDataType) {
+ EDataType datatype = (EDataType) feature.getEType();
return datatype.getName().equals("Boolean");
}
@@ -246,12 +247,12 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
}
protected boolean isInteger(EStructuralFeature feature) {
- if(feature.getEType() == EcorePackage.eINSTANCE.getEInt() || feature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
+ if (feature.getEType() == EcorePackage.eINSTANCE.getEInt() || feature.getEType() == EcorePackage.eINSTANCE.getEIntegerObject()) {
return true;
}
- if(feature.getEType() instanceof EDataType) {
- EDataType datatype = (EDataType)feature.getEType();
+ if (feature.getEType() instanceof EDataType) {
+ EDataType datatype = (EDataType) feature.getEType();
return datatype.getName().equals("Integer");
}
@@ -259,14 +260,14 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
}
protected Map<Declaration, Boolean> handleStyle(Style style) {
- if(style instanceof NamedStyle) {
+ if (style instanceof NamedStyle) {
return Collections.emptyMap();
}
Map<Declaration, Boolean> declarations = new LinkedHashMap<Declaration, Boolean>();
- for(EStructuralFeature feature : style.eClass().getEAllStructuralFeatures()) {
- if(NotationPackage.eINSTANCE.getStyle().isSuperTypeOf(feature.getEContainingClass())) {
+ for (EStructuralFeature feature : style.eClass().getEAllStructuralFeatures()) {
+ if (NotationPackage.eINSTANCE.getStyle().isSuperTypeOf(feature.getEContainingClass())) {
Object currentValue = style.eGet(feature);
Object defaultValue = feature.getDefaultValue();
boolean check = currentValue == null ? currentValue != defaultValue : !currentValue.equals(defaultValue);
@@ -277,8 +278,8 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
return declarations;
}
- //FIXME: Use constants for the CSS Properties names
- //FIXME: Use a helper to determine whether the custom styles are computed or forced
+ // FIXME: Use constants for the CSS Properties names
+ // FIXME: Use a helper to determine whether the custom styles are computed or forced
protected Map<Declaration, Boolean> handleCustomStyle(CustomStyle customStyle, View view) {
Map<Declaration, Boolean> declarations = new LinkedHashMap<Declaration, Boolean>();
@@ -306,30 +307,30 @@ public abstract class AbstractStyleHandler extends AbstractHandler {
GMFToCSSConverter converter = GMFToCSSConverter.instance;
- if(isString(feature)) {
- declaration.setExpression(converter.convert((String)style.eGet(feature)));
+ if (isString(feature)) {
+ declaration.setExpression(converter.convert((String) style.eGet(feature)));
}
- if(isInteger(feature)) {
- if(feature.getName().endsWith("Color")) {
- Color color = FigureUtilities.integerToColor((Integer)style.eGet(feature));
+ if (isInteger(feature)) {
+ if (feature.getName().endsWith("Color")) {
+ Color color = FigureUtilities.integerToColor((Integer) style.eGet(feature));
declaration.setExpression(converter.convert(color));
color.dispose();
} else {
- declaration.setExpression(converter.convert((Integer)style.eGet(feature)));
+ declaration.setExpression(converter.convert((Integer) style.eGet(feature)));
}
}
- if(feature.getEType() == NotationPackage.eINSTANCE.getGradientData()) {
- declaration.setExpression(converter.convert((GradientData)style.eGet(feature)));
+ if (feature.getEType() == NotationPackage.eINSTANCE.getGradientData()) {
+ declaration.setExpression(converter.convert((GradientData) style.eGet(feature)));
}
- if(feature.getEType() instanceof EEnum) {
- declaration.setExpression(converter.convert((Enumerator)style.eGet(feature)));
+ if (feature.getEType() instanceof EEnum) {
+ declaration.setExpression(converter.convert((Enumerator) style.eGet(feature)));
}
- if(isBoolean(feature)) {
- declaration.setExpression(converter.convert((Boolean)style.eGet(feature)));
+ if (isBoolean(feature)) {
+ declaration.setExpression(converter.convert((Boolean) style.eGet(feature)));
}
return declaration;
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java
index dcdff93531c..7fb52426147 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/CreateStyleHandler.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,18 +42,18 @@ public class CreateStyleHandler extends AbstractStyleHandler {
@Override
protected Stylesheet getStyleSheet(AbstractStyleDialog dialog, View contextView) {
- StyleSheet styleSheet = ((StyleCreationDialog)dialog).getStyleSheet();
+ StyleSheet styleSheet = ((StyleCreationDialog) dialog).getStyleSheet();
- if(styleSheet == null) {
+ if (styleSheet == null) {
MessageDialog.open(MessageDialog.ERROR, dialog.getShell(), "Stylesheet error", "Invalid stylesheet", SWT.NONE);
return null;
}
Resource resource;
- if(styleSheet instanceof StyleSheetReference) {
- resource = XtextStylesheetHelper.loadStylesheet((StyleSheetReference)styleSheet, null, contextView, dialog.getShell());
- if(resource == null) {
+ if (styleSheet instanceof StyleSheetReference) {
+ resource = XtextStylesheetHelper.loadStylesheet((StyleSheetReference) styleSheet, null, contextView, dialog.getShell());
+ if (resource == null) {
return null;
}
} else {
@@ -63,12 +63,12 @@ public class CreateStyleHandler extends AbstractStyleHandler {
Stylesheet xtextStylesheet;
- if(resource.getContents().isEmpty()) {
+ if (resource.getContents().isEmpty()) {
xtextStylesheet = CssFactory.eINSTANCE.createStylesheet();
xtextStylesheet.setCharset("UTF-8");
resource.getContents().add(xtextStylesheet);
} else {
- xtextStylesheet = (Stylesheet)resource.getContents().get(0);
+ xtextStylesheet = (Stylesheet) resource.getContents().get(0);
}
return xtextStylesheet;
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java
index 1fd90be5bea..a7c4d66f481 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/EditStyleHandler.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -30,7 +30,7 @@ public class EditStyleHandler extends AbstractStyleHandler {
@Override
protected Ruleset getRuleset(AbstractStyleDialog dialog) {
- Ruleset ruleset = ((StyleEditionDialog)dialog).getSelectedRuleset();
+ Ruleset ruleset = ((StyleEditionDialog) dialog).getSelectedRuleset();
ruleset.getSelectors().clear();
ruleset.getProperties().clear();
return ruleset;
@@ -38,7 +38,7 @@ public class EditStyleHandler extends AbstractStyleHandler {
@Override
protected Stylesheet getStyleSheet(AbstractStyleDialog dialog, View contextView) {
- return ((StyleEditionDialog)dialog).getStylesheet();
+ return ((StyleEditionDialog) dialog).getStylesheet();
}
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java
index f66a8fd7892..315e3e65de5 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/GMFToCSSConverter.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -58,14 +58,14 @@ public class GMFToCSSConverter {
private String twoDigitsHexString(int color) {
String hexString = Integer.toHexString(color);
- if(hexString.length() < 2) {
+ if (hexString.length() < 2) {
hexString = "0" + hexString;
}
return hexString;
}
public Expression convert(GradientData gradient) {
- if(gradient == null) {
+ if (gradient == null) {
Name noGradient = CssFactory.eINSTANCE.createName();
noGradient.setValue("none");
return getExpression(noGradient);
@@ -76,7 +76,7 @@ public class GMFToCSSConverter {
Name gradientStyle = CssFactory.eINSTANCE.createName();
int style = gradient.getGradientStyle();
- if(style == GradientStyle.HORIZONTAL) {
+ if (style == GradientStyle.HORIZONTAL) {
gradientStyle.setValue("horizontal");
} else {
gradientStyle.setValue("vertical");
@@ -94,7 +94,7 @@ public class GMFToCSSConverter {
public Expression convert(Integer intValue) {
Number numberValue = CssFactory.eINSTANCE.createNumber();
numberValue.setValue(Integer.toString(Math.abs(intValue)));
- if(intValue < 0) {
+ if (intValue < 0) {
UnaryOperator operator = CssFactory.eINSTANCE.createUnaryOperator();
operator.setOperator(UNARY.NEG);
numberValue.setOp(operator);
@@ -112,14 +112,14 @@ public class GMFToCSSConverter {
}
private Expression getExpression(Term... values) {
- if(values.length == 0) {
+ if (values.length == 0) {
throw new IllegalArgumentException("An expression must contain at least one value");
}
Expression result = CssFactory.eINSTANCE.createExpression();
result.setTerms(values[0]);
- for(int i = 1; i < values.length; i++) {
+ for (int i = 1; i < values.length; i++) {
Subterm subterm = CssFactory.eINSTANCE.createSubterm();
subterm.setTerm(values[i]);
result.getSubterms().add(subterm);
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java
index 99b19a7e4f5..017a8d46c46 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -51,12 +51,12 @@ public class StyleCreationDialog extends AbstractStyleDialog {
private StyleSheet stylesheet;
/**
- *
+ *
* @param shell
* @param conditions
- * inout
+ * inout
* @param declarations
- * inout
+ * inout
* @param selectorName
*/
public StyleCreationDialog(Shell shell, Map<Attribute, Boolean> conditions, Map<Declaration, Boolean> declarations, String selectorName, View context) {
@@ -87,14 +87,14 @@ public class StyleCreationDialog extends AbstractStyleDialog {
protected boolean isValid() {
boolean result = true;
- //There must be a stylesheet
- if(getStyleSheet() == null) {
+ // There must be a stylesheet
+ if (getStyleSheet() == null) {
setError("You must select a Stylesheet");
result = false;
}
- //EmbeddedStyleSheets are not yet supported
- if(getStyleSheet() instanceof EmbeddedStyleSheet) {
+ // EmbeddedStyleSheets are not yet supported
+ if (getStyleSheet() instanceof EmbeddedStyleSheet) {
setError("Edition of embedded stylesheets is not yet supported. Please select an external stylesheet");
result = false;
}
@@ -103,13 +103,13 @@ public class StyleCreationDialog extends AbstractStyleDialog {
}
protected void createStylesheet(Composite parent) {
- //TODO: Use a preference to remember the last edited Stylesheet (Per model? Diagram? Workspace? With user choice?)
+ // TODO: Use a preference to remember the last edited Stylesheet (Per model? Diagram? Workspace? With user choice?)
parent.setLayout(new GridLayout(1, false));
- //Create or use an existing External Stylesheet
+ // Create or use an existing External Stylesheet
externalStylesheetEditor = new StringFileSelector(parent, SWT.NONE);
- externalStylesheetEditor.setFilters(new String[]{ "*.css", "*" }, new String[]{ "CSS Stylesheets (*.css)", "All (*)" });
+ externalStylesheetEditor.setFilters(new String[] { "*.css", "*" }, new String[] { "CSS Stylesheets (*.css)", "All (*)" });
externalStylesheetEditor.setAllowFileSystem(false);
externalStylesheetEditor.setLabel("External stylesheet:");
externalStylesheetEditor.setToolTipText("Create or use an existing external CSS Stylesheet");
@@ -117,12 +117,12 @@ public class StyleCreationDialog extends AbstractStyleDialog {
externalStylesheetEditor.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- String path = (String)((StringEditor)editor).getValue();
+ String path = (String) ((StringEditor) editor).getValue();
- if((path != null && !"".equals(path)) || stylesheetSource == externalStylesheetEditor) {
+ if ((path != null && !"".equals(path)) || stylesheetSource == externalStylesheetEditor) {
StyleSheetReference stylesheetReference = null;
- if(path != null && !"".equals(path)) {
+ if (path != null && !"".equals(path)) {
stylesheetReference = StylesheetsFactory.eINSTANCE.createStyleSheetReference();
stylesheetReference.setPath(path);
}
@@ -137,22 +137,22 @@ public class StyleCreationDialog extends AbstractStyleDialog {
Label orLabel = new Label(parent, SWT.NONE);
orLabel.setText("-- OR --");
- //Create a new Embedded Stylesheet
+ // Create a new Embedded Stylesheet
embeddedStylesheetEditor = new StringEditor(parent, SWT.NONE);
embeddedStylesheetEditor.setLabel("New local stylesheet:");
- //FIXME: Change the tooltip text when the X-Text editor can edit local stylesheets
+ // FIXME: Change the tooltip text when the X-Text editor can edit local stylesheets
embeddedStylesheetEditor.setToolTipText("Enter the new local stylesheet's name");
- // embeddedStylesheetEditor.setToolTipText("Create a new local stylesheet. The stylesheet will be embedded in the current model. Unsupported yet");
+ // embeddedStylesheetEditor.setToolTipText("Create a new local stylesheet. The stylesheet will be embedded in the current model. Unsupported yet");
- //FIXME: Set read only to false when the X-Text editor can edit local stylesheets
+ // FIXME: Set read only to false when the X-Text editor can edit local stylesheets
embeddedStylesheetEditor.setReadOnly(true);
embeddedStylesheetEditor.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
embeddedStylesheetEditor.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- //TODO: Check empty names & set the stylesheet to null when the name is null/empty
- String name = (String)((StringEditor)editor).getValue();
+ // TODO: Check empty names & set the stylesheet to null when the name is null/empty
+ String name = (String) ((StringEditor) editor).getValue();
EmbeddedStyleSheet embeddedStylesheet = StylesheetsFactory.eINSTANCE.createEmbeddedStyleSheet();
embeddedStylesheet.setLabel(name);
stylesheet = embeddedStylesheet;
@@ -164,7 +164,7 @@ public class StyleCreationDialog extends AbstractStyleDialog {
orLabel = new Label(parent, SWT.NONE);
orLabel.setText("-- OR --");
- //Use an existing applied stylesheet (Either Reference or Embedded)
+ // Use an existing applied stylesheet (Either Reference or Embedded)
appliedStylesheetEditor = new ReferenceDialog(parent, SWT.NONE);
appliedStylesheetEditor.setLabel("Applied stylesheet:");
appliedStylesheetEditor.setToolTipText("Use an existing stylesheet, from the stylesheets applied to the current model");
@@ -174,8 +174,8 @@ public class StyleCreationDialog extends AbstractStyleDialog {
appliedStylesheetEditor.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- StyleSheet value = (StyleSheet)((ReferenceDialog)editor).getValue();
- if(!(ignoreEvents && value == null)) {
+ StyleSheet value = (StyleSheet) ((ReferenceDialog) editor).getValue();
+ if (!(ignoreEvents && value == null)) {
stylesheet = value;
resetStylesheetEditors(appliedStylesheetEditor);
}
@@ -186,20 +186,20 @@ public class StyleCreationDialog extends AbstractStyleDialog {
}
private void resetStylesheetEditors(AbstractEditor stylesheetSource) {
- if(ignoreEvents) {
+ if (ignoreEvents) {
return;
}
ignoreEvents = true;
- if(stylesheetSource != externalStylesheetEditor) {
+ if (stylesheetSource != externalStylesheetEditor) {
externalStylesheetEditor.setValue(null);
}
- if(stylesheetSource != embeddedStylesheetEditor) {
+ if (stylesheetSource != embeddedStylesheetEditor) {
embeddedStylesheetEditor.setValue(null);
}
- if(stylesheetSource != appliedStylesheetEditor) {
+ if (stylesheetSource != appliedStylesheetEditor) {
appliedStylesheetEditor.setValue(null);
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java
index 4f8e3732047..2ad53e45167 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleEditionDialog.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -44,16 +44,16 @@ import org.eclipse.swt.widgets.Shell;
/**
* A dialog for editing an existing CSS Style, based on a selected element
- *
+ *
* @author Camille Letavernier
*/
-//TODO: When a condition or property doesn't exist on the selected element,
-//but exists in the selected style, add it to #declarations/#conditions
-//TODO: Delete an existing style?
-//TODO: Use a combo-box + ListViewer instead of a TreeViewer
-//TODO: Remove read-only stylesheets (Or add a warning/Error when a ruleset from a readonly stylesheet is selected)
-//TODO: Load an external stylesheet (Which is not yet applied on the diagram)
-//TODO: Support embedded stylesheets
+// TODO: When a condition or property doesn't exist on the selected element,
+// but exists in the selected style, add it to #declarations/#conditions
+// TODO: Delete an existing style?
+// TODO: Use a combo-box + ListViewer instead of a TreeViewer
+// TODO: Remove read-only stylesheets (Or add a warning/Error when a ruleset from a readonly stylesheet is selected)
+// TODO: Load an external stylesheet (Which is not yet applied on the diagram)
+// TODO: Support embedded stylesheets
public class StyleEditionDialog extends AbstractStyleDialog implements ISelectionChangedListener {
protected Composite styleSelectionPanel;
@@ -63,12 +63,12 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
protected Ruleset ruleset;
/**
- *
+ *
* @param shell
* @param conditions
- * inout
+ * inout
* @param declarations
- * inout
+ * inout
* @param selectorName
*/
public StyleEditionDialog(Shell shell, Map<Attribute, Boolean> conditions, Map<Declaration, Boolean> declarations, String selectorName, View context) {
@@ -80,19 +80,19 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
super.create();
createStyleSelectionPanel();
getShell().setText("Edit an existing style");
- // getShell().pack();
+ // getShell().pack();
}
@Override
public Composite createDialogArea(Composite parent) {
- Composite dialogArea = (Composite)super.createDialogArea(parent);
+ Composite dialogArea = (Composite) super.createDialogArea(parent);
SashForm sash = new SashForm(dialogArea, SWT.HORIZONTAL);
sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- // GridLayout parentLayout = (GridLayout)dialogArea.getLayout();
- // parentLayout.numColumns = 2;
- // parentLayout.makeColumnsEqualWidth = false;
+ // GridLayout parentLayout = (GridLayout)dialogArea.getLayout();
+ // parentLayout.numColumns = 2;
+ // parentLayout.makeColumnsEqualWidth = false;
styleSelectionPanel = new Composite(sash, SWT.NONE);
@@ -104,18 +104,18 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
styleEditionPanel = new Composite(sash, SWT.NONE);
styleEditionPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout layout = new GridLayout(1, true);
- // layout.marginWidth = 0;
- // layout.marginHeight = 0;
+ // layout.marginWidth = 0;
+ // layout.marginHeight = 0;
styleEditionPanel.setLayout(layout);
- sash.setWeights(new int[]{ 2, 5 });
+ sash.setWeights(new int[] { 2, 5 });
return styleEditionPanel;
}
protected void createStyleSelectionPanel() {
- // styleSelectionPanel.setBackground(styleSelectionPanel.getDisplay().getSystemColor(SWT.COLOR_WHITE));
- // styleSelectionPanel.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ // styleSelectionPanel.setBackground(styleSelectionPanel.getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ // styleSelectionPanel.setBackgroundMode(SWT.INHERIT_DEFAULT);
TreeViewer viewer = new TreeViewer(styleSelectionPanel, SWT.BORDER);
viewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.setContentProvider(new ExistingStyleContentProvider(contextView));
@@ -127,8 +127,8 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
}
protected Stylesheet getStylesheet() {
- if(ruleset != null) {
- return (Stylesheet)ruleset.eContainer();
+ if (ruleset != null) {
+ return (Stylesheet) ruleset.eContainer();
}
return null;
}
@@ -139,15 +139,15 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
- if(selection.isEmpty()) {
- //TODO: Conditions + Declaration -> Readonly
+ if (selection.isEmpty()) {
+ // TODO: Conditions + Declaration -> Readonly
}
- if(selection instanceof IStructuredSelection) {
- IStructuredSelection sSelection = (IStructuredSelection)selection;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection sSelection = (IStructuredSelection) selection;
Object selectedElement = sSelection.getFirstElement();
- if(selectedElement instanceof Ruleset) {
- handleSelectionChanged((Ruleset)selectedElement);
+ if (selectedElement instanceof Ruleset) {
+ handleSelectionChanged((Ruleset) selectedElement);
} else {
ruleset = null;
}
@@ -159,13 +159,13 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
protected void handleSelectionChanged(Ruleset selectedRuleset) {
this.ruleset = selectedRuleset;
- //Sets all conditions to false. They will be set to true if the selected style contains the same condition
- for(Attribute attribute : conditions.keySet()) {
+ // Sets all conditions to false. They will be set to true if the selected style contains the same condition
+ for (Attribute attribute : conditions.keySet()) {
conditions.put(attribute, false);
}
- //Sets all properties to false. They will be set to true if the selected style contains the same property
- for(Declaration declaration : declarations.keySet()) {
+ // Sets all properties to false. They will be set to true if the selected style contains the same property
+ for (Declaration declaration : declarations.keySet()) {
declarations.put(declaration, false);
}
@@ -175,7 +175,7 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
cssClass = null;
- for(Selector selector : selectedRuleset.getSelectors()) {
+ for (Selector selector : selectedRuleset.getSelectors()) {
handleSelector(selector);
}
@@ -186,9 +186,9 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
}
protected void handleDeclarations(List<Declaration> declarations) {
- for(Declaration declaration : declarations) {
- for(Declaration currentDeclaration : this.declarations.keySet()) {
- if(currentDeclaration.getProperty().equals(declaration.getProperty())) {
+ for (Declaration declaration : declarations) {
+ for (Declaration currentDeclaration : this.declarations.keySet()) {
+ if (currentDeclaration.getProperty().equals(declaration.getProperty())) {
this.declarations.put(currentDeclaration, true);
break;
}
@@ -197,33 +197,33 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
}
protected void handleSelector(Selector selector) {
- if(selector instanceof SimpleSelector) {
- handleSelector((SimpleSelector)selector);
- } else if(selector instanceof CompositeSelector) {
- handleSelector((CompositeSelector)selector);
+ if (selector instanceof SimpleSelector) {
+ handleSelector((SimpleSelector) selector);
+ } else if (selector instanceof CompositeSelector) {
+ handleSelector((CompositeSelector) selector);
}
}
protected void handleSelector(SimpleSelector selector) {
- if(getDiagramType(contextView.getDiagram()).equals(selector.getElementName())) {
+ if (getDiagramType(contextView.getDiagram()).equals(selector.getElementName())) {
diagramRestriction = true;
}
- if(contextView.getElement().eClass().getName().equals(selector.getElementName())) {
+ if (contextView.getElement().eClass().getName().equals(selector.getElementName())) {
useSelectorName = true;
}
- for(SelectorCondition condition : selector.getCondition()) {
- if(condition instanceof Attribute) {
- Attribute existingAttribute = (Attribute)condition;
- for(Attribute selectedAttribute : conditions.keySet()) {
- if(existingAttribute.getName().equals(selectedAttribute.getName())) {
+ for (SelectorCondition condition : selector.getCondition()) {
+ if (condition instanceof Attribute) {
+ Attribute existingAttribute = (Attribute) condition;
+ for (Attribute selectedAttribute : conditions.keySet()) {
+ if (existingAttribute.getName().equals(selectedAttribute.getName())) {
conditions.put(selectedAttribute, true);
break;
}
}
- } else if(condition.eClass() == CssPackage.eINSTANCE.getClass_()) {
- cssClass = ((org.eclipse.papyrus.infra.gmfdiag.css.Class)condition).getClass_();
+ } else if (condition.eClass() == CssPackage.eINSTANCE.getClass_()) {
+ cssClass = ((org.eclipse.papyrus.infra.gmfdiag.css.Class) condition).getClass_();
}
}
}
@@ -242,7 +242,7 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
}
protected void disposeContents(Composite composite) {
- for(Control control : composite.getChildren()) {
+ for (Control control : composite.getChildren()) {
control.dispose();
}
}
@@ -256,7 +256,7 @@ public class StyleEditionDialog extends AbstractStyleDialog implements ISelectio
protected boolean isValid() {
boolean result = true;
- if(ruleset == null) {
+ if (ruleset == null) {
setError("You must select an existing Style");
result = false;
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/DiagramTypeHelper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/DiagramTypeHelper.java
index 87531d44843..eb739d6c707 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/DiagramTypeHelper.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/DiagramTypeHelper.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,12 +19,12 @@ import org.eclipse.gmf.runtime.notation.Diagram;
/**
* Helper to convert from the implementation-based Diagram Type (e.g. PapyrusUMLClassDiagram) to a more
* user-readable (and consistent) Diagram name, used in CSS Stylesheets (e.g. ClassDiagram)
- *
+ *
* @author Camille Letavernier
*/
-//TODO : Replace with an extension point, so that it is possible to use this kind of Label
-//anywhere in Papyrus (Preferences, CSS Stylesheets, property view, ...)
-//See org.eclipse.papyrus.infra.gmfdiag.css.GMFElementAdapter
+// TODO : Replace with an extension point, so that it is possible to use this kind of Label
+// anywhere in Papyrus (Preferences, CSS Stylesheets, property view, ...)
+// See org.eclipse.papyrus.infra.gmfdiag.css.GMFElementAdapter
public class DiagramTypeHelper {
public static String getDiagramType(Diagram diagram) {
@@ -35,7 +35,7 @@ public class DiagramTypeHelper {
private static Map<String, String> diagramNameMappings = new HashMap<String, String>();
static {
- //UML
+ // UML
diagramNameMappings.put("CompositeStructure", "CompositeDiagram");
diagramNameMappings.put("Package", "PackageDiagram");
diagramNameMappings.put("PapyrusUMLActivityDiagram", "ActivityDiagram");
@@ -48,7 +48,7 @@ public class DiagramTypeHelper {
diagramNameMappings.put("PapyrusUMLStateMachineDiagram", "StateMachineDiagram");
diagramNameMappings.put("UseCase", "UseCaseDiagram");
- //SysML
+ // SysML
diagramNameMappings.put("BlockDefinition", "BlockDiagram");
diagramNameMappings.put("InternalBlock", "InternalBlockDiagram");
diagramNameMappings.put("PapyrusSysMLRequirement", "RequirementDiagram");
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/XtextStylesheetHelper.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/XtextStylesheetHelper.java
index 3fff0e46641..0ffbcec1ec7 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/XtextStylesheetHelper.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/helper/XtextStylesheetHelper.java
@@ -35,21 +35,21 @@ public class XtextStylesheetHelper {
* Loads and returns a Resource containing an XText Stylesheet
*
* @param stylesheet
- * The object representing the Stylesheet's path or contents
+ * The object representing the Stylesheet's path or contents
* @param resourceSet
- * The resourceSet in which the resource will be loaded. May be null.
+ * The resourceSet in which the resource will be loaded. May be null.
* @param contextView
- * The context view. If the stylesheet's path is relative, it will be resolved against this view's URI.
+ * The context view. If the stylesheet's path is relative, it will be resolved against this view's URI.
* @param parentShell
- * The shell used to open error dialogs. May be null
+ * The shell used to open error dialogs. May be null
* @return
* A resource containing the loaded stylesheet, or null if the stylesheet could not be resolved or is invalid
*/
public static Resource loadStylesheet(StyleSheet stylesheet, ResourceSet resourceSet, View contextView, Shell parentShell) {
- if(stylesheet instanceof StyleSheetReference) {
- return loadStylesheet((StyleSheetReference)stylesheet, resourceSet, contextView, parentShell);
- } else if(stylesheet instanceof EmbeddedStyleSheet) {
- //TODO: Edit EmbeddedStyleSheets with XText
+ if (stylesheet instanceof StyleSheetReference) {
+ return loadStylesheet((StyleSheetReference) stylesheet, resourceSet, contextView, parentShell);
+ } else if (stylesheet instanceof EmbeddedStyleSheet) {
+ // TODO: Edit EmbeddedStyleSheets with XText
throw new UnsupportedOperationException();
}
return null;
@@ -59,39 +59,39 @@ public class XtextStylesheetHelper {
* Loads and returns a Resource containing an XText Stylesheet
*
* @param stylesheet
- * The object representing the Stylesheet's path
+ * The object representing the Stylesheet's path
* @param resourceSet
- * The resourceSet in which the resource will be loaded. May be null.
+ * The resourceSet in which the resource will be loaded. May be null.
* @param contextView
- * The context view. If the stylesheet's path is relative, it will be resolved against this view's URI.
+ * The context view. If the stylesheet's path is relative, it will be resolved against this view's URI.
* @param parentShell
- * The shell used to open error dialogs. May be null
+ * The shell used to open error dialogs. May be null
* @return
* A resource containing the loaded stylesheet, or null if the stylesheet could not be resolved or is invalid
*/
public static Resource loadStylesheet(StyleSheetReference stylesheet, ResourceSet resourceSet, View contextView, Shell parentShell) {
- if(resourceSet == null) {
+ if (resourceSet == null) {
resourceSet = new XtextResourceSet();
}
- //Supported pathes:
+ // Supported pathes:
// /<plugin>/path/file.css (Workspace, platform:/resource/)
// relative/path/file.css (Relative)
String path = stylesheet.getPath();
- if(!path.endsWith(".css")) {
- //FIXME: The X-Text editor supports CSS Content Types, but it is not yet configured
- //to automatically accept other extensions than *.css
- //The parser should rely on the file's content type instead of the file extension
- //Attemps to serialize to a custom extension (even an extension compatible with CSS Content Type)
- //would result in xmi serialization. We'd better stop here.
- if(parentShell != null) {
+ if (!path.endsWith(".css")) {
+ // FIXME: The X-Text editor supports CSS Content Types, but it is not yet configured
+ // to automatically accept other extensions than *.css
+ // The parser should rely on the file's content type instead of the file extension
+ // Attemps to serialize to a custom extension (even an extension compatible with CSS Content Type)
+ // would result in xmi serialization. We'd better stop here.
+ if (parentShell != null) {
MessageDialog.open(MessageDialog.ERROR, parentShell, "Stylesheet error", "The stylesheet must have the *.css extension", SWT.NONE);
}
return null;
}
URI uri;
- if(path.startsWith("/")) {
+ if (path.startsWith("/")) {
uri = URI.createPlatformResourceURI(path, true);
} else {
uri = URI.createURI(path);
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java
index a5b76514954..fb54c330335 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/ExistingStyleContentProvider.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -44,22 +44,22 @@ public class ExistingStyleContentProvider implements IHierarchicContentProvider
public Object[] getElements(Object inputElement) {
Collection<StyleSheet> stylesheets = getStyleSheets();
- if(stylesheets.isEmpty()) {
- //Display a message to let the user know why he cannot edit a stylesheet
- return new Object[]{ "No stylesheet available" };
+ if (stylesheets.isEmpty()) {
+ // Display a message to let the user know why he cannot edit a stylesheet
+ return new Object[] { "No stylesheet available" };
}
return stylesheets.toArray();
}
public Object[] getChildren(Object parentElement) {
- if(parentElement instanceof StyleSheet) {
+ if (parentElement instanceof StyleSheet) {
Stylesheet xtextStylesheet = stylesheets.get(parentElement);
List<Ruleset> result = new LinkedList<Ruleset>();
- for(Content stylesheetElement : xtextStylesheet.getContents()) {
- if(stylesheetElement instanceof Ruleset) {
- result.add((Ruleset)stylesheetElement);
+ for (Content stylesheetElement : xtextStylesheet.getContents()) {
+ if (stylesheetElement instanceof Ruleset) {
+ result.add((Ruleset) stylesheetElement);
}
}
@@ -70,12 +70,12 @@ public class ExistingStyleContentProvider implements IHierarchicContentProvider
}
public Object getParent(Object element) {
- if(element instanceof Stylesheet) {
+ if (element instanceof Stylesheet) {
return null;
}
- if(element instanceof Ruleset) {
- return ((Ruleset)element).eContainer();
+ if (element instanceof Ruleset) {
+ return ((Ruleset) element).eContainer();
}
return null;
@@ -98,10 +98,10 @@ public class ExistingStyleContentProvider implements IHierarchicContentProvider
}
protected Collection<StyleSheet> getStyleSheets() {
- if(stylesheets == null) {
+ if (stylesheets == null) {
stylesheets = new LinkedHashMap<StyleSheet, Stylesheet>();
- if(context.getDiagram() instanceof CSSDiagram) {
- CSSDiagram diagram = (CSSDiagram)context.getDiagram();
+ if (context.getDiagram() instanceof CSSDiagram) {
+ CSSDiagram diagram = (CSSDiagram) context.getDiagram();
parseStyleSheets(diagram.getStyleSheets());
}
}
@@ -109,24 +109,24 @@ public class ExistingStyleContentProvider implements IHierarchicContentProvider
}
protected void parseStyleSheets(List<StyleSheet> appliedStylesheets) {
- for(StyleSheet stylesheet : appliedStylesheets) {
- if(stylesheet instanceof StyleSheetReference) {
- parseStyleSheet((StyleSheetReference)stylesheet);
- } else if(stylesheet instanceof EmbeddedStyleSheet) {
- //Unsupported yet
+ for (StyleSheet stylesheet : appliedStylesheets) {
+ if (stylesheet instanceof StyleSheetReference) {
+ parseStyleSheet((StyleSheetReference) stylesheet);
+ } else if (stylesheet instanceof EmbeddedStyleSheet) {
+ // Unsupported yet
}
}
}
protected void parseStyleSheet(StyleSheetReference stylesheet) {
Resource resource = XtextStylesheetHelper.loadStylesheet(stylesheet, null, context, null);
- if(resource.getContents().isEmpty()) {
+ if (resource.getContents().isEmpty()) {
return;
}
- for(EObject rootElement : resource.getContents()) {
- if(rootElement instanceof Stylesheet) {
- stylesheets.put(stylesheet, (Stylesheet)rootElement);
+ for (EObject rootElement : resource.getContents()) {
+ if (rootElement instanceof Stylesheet) {
+ stylesheets.put(stylesheet, (Stylesheet) rootElement);
}
}
}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java
index 19ab6c6b34a..976617b27e6 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/providers/StylesheetLabelProvider.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,28 +40,28 @@ public class StylesheetLabelProvider extends EMFLabelProvider {
@Override
public String getText(Object element) {
- if(element instanceof Ruleset) {
- return getText((Ruleset)element);
+ if (element instanceof Ruleset) {
+ return getText((Ruleset) element);
}
- if(element instanceof StyleSheetReference) {
- return getText((StyleSheetReference)element);
+ if (element instanceof StyleSheetReference) {
+ return getText((StyleSheetReference) element);
}
- if(element instanceof EmbeddedStyleSheet) {
- return getText((EmbeddedStyleSheet)element);
+ if (element instanceof EmbeddedStyleSheet) {
+ return getText((EmbeddedStyleSheet) element);
}
return super.getText(element);
}
public String getText(Ruleset ruleset) {
- //Delegate the label to XText serialization
+ // Delegate the label to XText serialization
String label = "";
- if(!ruleset.getSelectors().isEmpty()) {
+ if (!ruleset.getSelectors().isEmpty()) {
label += serializer.serialize(ruleset.getSelectors().get(0));
- for(int i = 1; i < ruleset.getSelectors().size(); i++) {
+ for (int i = 1; i < ruleset.getSelectors().size(); i++) {
label += ", " + serializer.serialize(ruleset.getSelectors().get(i));
}
label = label.trim().replaceAll("\\s+", " ");
@@ -80,7 +80,7 @@ public class StylesheetLabelProvider extends EMFLabelProvider {
@Override
public Color getForeground(Object element) {
- if(!(element instanceof Ruleset)) {
+ if (!(element instanceof Ruleset)) {
return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY);
}
return super.getForeground(element);
@@ -88,9 +88,9 @@ public class StylesheetLabelProvider extends EMFLabelProvider {
@Override
public Image getImage(Object element) {
- // if(element instanceof StyleSheetReference) {
- // return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, "/icons/sourceEditor.gif");
- // }
+ // if(element instanceof StyleSheetReference) {
+ // return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, "/icons/sourceEditor.gif");
+ // }
return null;
}
}

Back to the top