Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-04-02 11:57:32 -0400
committercletavernie2012-04-02 11:57:32 -0400
commitb19c128f861a85fcc1292a528dcf6fa6bb19e6ab (patch)
treec709637e2ce855661672a2b9e8f4778bf7dca0b5 /plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration
parent3235733789ac89fc6ba6c1d709f64638034c07ad (diff)
downloadorg.eclipse.papyrus-b19c128f861a85fcc1292a528dcf6fa6bb19e6ab.tar.gz
org.eclipse.papyrus-b19c128f861a85fcc1292a528dcf6fa6bb19e6ab.tar.xz
org.eclipse.papyrus-b19c128f861a85fcc1292a528dcf6fa6bb19e6ab.zip
370797: [Theme] Papyrus should provide a support for CSS files on its diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370797
Diffstat (limited to 'plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css.configuration/src/org/eclipse/papyrus/infra/gmfdiag/css/configuration/handler/StyleCreationDialog.java88
1 files changed, 79 insertions, 9 deletions
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 5a0eda76c54..3e5c7d8b8c6 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
@@ -14,6 +14,7 @@ package org.eclipse.papyrus.infra.gmfdiag.css.configuration.handler;
import java.util.Map;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -43,6 +44,7 @@ import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
import org.eclipse.papyrus.infra.widgets.editors.StringFileSelector;
import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.GridData;
@@ -70,6 +72,8 @@ public class StyleCreationDialog extends TrayDialog {
private StyleSheet stylesheet;
+ private CLabel errorLabel;
+
/**
*
* @param shell
@@ -93,7 +97,7 @@ public class StyleCreationDialog extends TrayDialog {
Composite parent = getDialogArea();
CTabFolder tabFolder = new CTabFolder(parent, SWT.BORDER);
- tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
CTabItem conditionsTab = new CTabItem(tabFolder, SWT.NONE);
CTabItem declarationsTab = new CTabItem(tabFolder, SWT.NONE);
@@ -128,10 +132,68 @@ public class StyleCreationDialog extends TrayDialog {
createDeclarations(declarationsContainer);
createStylesheet(stylesheetContainer);
+ updateButtons();
+
getShell().setText("New Style");
getShell().pack();
}
+ protected void updateButtons() {
+ //Resets the error message
+ setError(null);
+ getButton(IDialogConstants.OK_ID).setEnabled(isValid());
+ getDialogArea().layout();
+ }
+
+ protected boolean isValid() {
+ boolean result = true;
+
+ //There must be a stylesheet
+ if(getStylesheet() == null) {
+ setError("You must select a Stylesheet");
+ result = false;
+ }
+
+ //There must be at least one property declaration
+ boolean atLeastOneDeclaration = false;
+ for(Boolean value : declarations.values()) {
+ if(value) {
+ atLeastOneDeclaration = true;
+ break;
+ }
+ }
+
+ result = result && atLeastOneDeclaration;
+
+ if(!atLeastOneDeclaration) {
+ setError("There must be at least one property declaration");
+ }
+
+ return result;
+ }
+
+ protected void setError(String errorMessage) {
+ if(errorMessage == null && errorLabel != null) {
+ errorLabel.dispose();
+ errorLabel = null;
+ return;
+ }
+
+ 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("")) {
+ errorLabel.setText(errorLabel.getText() + "\n" + errorMessage);
+ } else {
+ errorLabel.setText(errorMessage);
+ }
+ }
+ }
+
protected void createConditions(Composite parent) {
parent.setLayout(new GridLayout(3, false));
@@ -206,7 +268,6 @@ public class StyleCreationDialog extends TrayDialog {
}
BooleanCheckbox checkbox = new BooleanCheckbox(parent, SWT.NONE, attributeLabel);
- checkbox.setValue(conditions.get(currentCondition));
checkbox.addCommitListener(new ICommitListener() {
@@ -227,7 +288,6 @@ public class StyleCreationDialog extends TrayDialog {
StringEditor styleNameEditor = new StringEditor(parent, SWT.NONE, "Style name:");
styleNameEditor.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1));
- // styleNameEditor.setToolTipText(label);
styleNameEditor.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
@@ -239,7 +299,6 @@ public class StyleCreationDialog extends TrayDialog {
protected void createDeclarations(Composite parent) {
parent.setLayout(new GridLayout(3, false));
- // parent.setLayout(new FillLayout());
Label declarationsLabel = new Label(parent, SWT.WRAP);
declarationsLabel.setText("Select the properties you want to set. Unchecked properties will keep their default value (Which might be inherited from another style).");
@@ -248,15 +307,21 @@ public class StyleCreationDialog extends TrayDialog {
for(Declaration declaration : declarations.keySet()) {
String label = declaration.getProperty() + ": " + getLabel(declaration.getExpression());
BooleanCheckbox checkbox = new BooleanCheckbox(parent, SWT.NONE, label);
- checkbox.setValue(declarations.get(declaration));
final Declaration currentDeclaration = declaration;
+
+ checkbox.setValue(declarations.get(currentDeclaration));
+
checkbox.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- declarations.put(currentDeclaration, ((BooleanCheckbox)editor).getValue());
+ boolean value = ((BooleanCheckbox)editor).getValue();
+ declarations.put(currentDeclaration, value);
+ updateButtons();
}
});
+
+ checkbox.setValue(declarations.get(declaration));
}
}
@@ -275,9 +340,12 @@ public class StyleCreationDialog extends TrayDialog {
public void commit(AbstractEditor editor) {
String path = (String)((StringEditor)editor).getValue();
- StyleSheetReference stylesheetReference = StylesheetsFactory.eINSTANCE.createStyleSheetReference();
- stylesheetReference.setPath(path);
- stylesheet = stylesheetReference;
+ if(path != null && !"".equals(path)) {
+ StyleSheetReference stylesheetReference = StylesheetsFactory.eINSTANCE.createStyleSheetReference();
+ stylesheetReference.setPath(path);
+ stylesheet = stylesheetReference;
+ updateButtons();
+ }
}
});
@@ -297,6 +365,7 @@ public class StyleCreationDialog extends TrayDialog {
EmbeddedStyleSheet embeddedStylesheet = StylesheetsFactory.eINSTANCE.createEmbeddedStyleSheet();
embeddedStylesheet.setLabel(name);
stylesheet = embeddedStylesheet;
+ updateButtons();
}
});
@@ -315,6 +384,7 @@ public class StyleCreationDialog extends TrayDialog {
public void commit(AbstractEditor editor) {
StyleSheet value = (StyleSheet)((ReferenceDialog)editor).getValue();
stylesheet = value;
+ updateButtons();
}
});

Back to the top