瀏覽代碼

Created and implmented decorator for labs examples (#1865)

svenjawendler 7 年之前
父節點
當前提交
1e28d489de

+ 56 - 54
plugins/org.yakindu.sct.examples.wizard/src/org/yakindu/sct/examples/wizard/pages/ExampleLabelProvider.java

@@ -1,54 +1,56 @@
-/**
- * Copyright (c) 2016 committers of YAKINDU 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
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.examples.wizard.pages;
-
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.swt.graphics.Image;
-import org.yakindu.sct.examples.wizard.pages.ExampleContentProvider.Category;
-import org.yakindu.sct.examples.wizard.service.ExampleData;
-import org.yakindu.sct.ui.editor.StatechartImages;
-
-/**
- * 
- * @author t00manysecretss
- * 
- */
-public class ExampleLabelProvider extends LabelProvider implements IStyledLabelProvider {
-
-	@Override
-	public StyledString getStyledText(Object element) {
-		if (element instanceof ExampleData) {
-			return new StyledString(((ExampleData) element).getTitle());
-		} else if (element instanceof Category) {
-			return new StyledString(((Category) element).getName());
-		}
-		return null;
-	}
-
-	@Override
-	public Image getImage(Object element) {
-		if (element instanceof ExampleData) {
-			if (((ExampleData) element).isProfessional()) {
-				return StatechartImages.PRO_LOGO.image();
-			} else {
-				return StatechartImages.LOGO.image();
-			}
-		}
-		return StatechartImages.MENU.image();
-	}
-
-	@Override
-	public void dispose() {
-	}
-
-}
+/**
+ * Copyright (c) 2016 committers of YAKINDU 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.examples.wizard.pages;
+
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.yakindu.sct.examples.wizard.pages.ExampleContentProvider.Category;
+import org.yakindu.sct.examples.wizard.service.ExampleData;
+import org.yakindu.sct.ui.editor.StatechartImages;
+
+/**
+ * 
+ * @author t00manysecretss
+ * 
+ */
+public class ExampleLabelProvider extends LabelProvider implements IStyledLabelProvider {
+
+	@Override
+	public StyledString getStyledText(Object element) {
+		if (element instanceof ExampleData) {
+			return new StyledString(((ExampleData) element).getTitle());
+		} else if (element instanceof Category) {
+			return new StyledString(((Category) element).getName());
+		}
+		return null;
+	}
+
+	@Override
+	public Image getImage(Object element) {
+		if (element instanceof ExampleData) {
+			if (((ExampleData) element).isProfessional()) {
+				return StatechartImages.PRO_LOGO.image();
+			} else if (((ExampleData) element).isLabs()){
+				return StatechartImages.LABS_LOGO.image();
+			} else {
+				return StatechartImages.LOGO.image();
+			}
+		}
+		return StatechartImages.MENU.image();
+	}
+
+	@Override
+	public void dispose() {
+	}
+
+}

+ 162 - 157
plugins/org.yakindu.sct.examples.wizard/src/org/yakindu/sct/examples/wizard/service/ExampleData.java

@@ -1,158 +1,163 @@
-/**
- * Copyright (c) 2016 committers of YAKINDU 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
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributors:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.examples.wizard.service;
-
-import java.io.File;
-import java.text.Collator;
-import java.util.Arrays;
-
-/**
- * 
- * @author t00manysecretss
- * 
- */
-public class ExampleData implements Comparable<ExampleData> {
-
-	private static final String PRO_EXAMPLE = "professional";
-	private String id;
-	private String title;
-	private String[] category;
-	private String description;
-	private String[] images;
-	private File projectDir;
-
-	public ExampleData(String category[], String id, String title, String description, String[] images) {
-		this.category = category;
-		this.id = id;
-		this.title = title;
-		this.description = description;
-		this.images = images;
-	}
-
-	public String getId() {
-		return id;
-	}
-
-	public void setId(String id) {
-		this.id = id;
-	}
-
-	public String getTitle() {
-		return title;
-	}
-
-	public void setTitle(String title) {
-		this.title = title;
-	}
-
-	public String[] getCategory() {
-		return category;
-	}
-
-	public void setCategory(String[] category) {
-		this.category = category;
-	}
-
-	public String getDescription() {
-		return description;
-	}
-
-	public void setDescription(String description) {
-		this.description = description;
-	}
-
-	public String[] getImages() {
-		return images;
-	}
-
-	public String[] getFullImagePathes() {
-		String[] result = new String[images.length];
-		String[] imgs = getImages();
-		for (int i = 0; i < imgs.length; i++) {
-			result[i] = getProjectDir() + File.separator + imgs[i];
-		}
-		return result;
-	}
-
-	public void setImages(String[] images) {
-		this.images = images;
-	}
-
-	public File getProjectDir() {
-		return projectDir;
-	}
-
-	public void setProjectDir(File projectDir) {
-		this.projectDir = projectDir;
-	}
-
-	public boolean isProfessional() {
-		return Arrays.asList(getCategory()).contains(PRO_EXAMPLE);
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result + ((description == null) ? 0 : description.hashCode());
-		result = prime * result + ((category == null) ? 0 : category.hashCode());
-		result = prime * result + ((id == null) ? 0 : id.hashCode());
-		result = prime * result + Arrays.hashCode(images);
-		result = prime * result + ((projectDir == null) ? 0 : projectDir.hashCode());
-		result = prime * result + ((title == null) ? 0 : title.hashCode());
-		return result;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		ExampleData other = (ExampleData) obj;
-		if (description == null) {
-			if (other.description != null)
-				return false;
-		} else if (!description.equals(other.description))
-			return false;
-		if (category == null) {
-			if (other.category != null)
-				return false;
-		} else if (!category.equals(other.category))
-			return false;
-		if (id == null) {
-			if (other.id != null)
-				return false;
-		} else if (!id.equals(other.id))
-			return false;
-		if (!Arrays.equals(images, other.images))
-			return false;
-		if (projectDir == null) {
-			if (other.projectDir != null)
-				return false;
-		} else if (!projectDir.equals(other.projectDir))
-			return false;
-		if (title == null) {
-			if (other.title != null)
-				return false;
-		} else if (!title.equals(other.title))
-			return false;
-		return true;
-	}
-
-	@Override
-	public int compareTo(ExampleData other) {
-		return Collator.getInstance().compare(this.title, other.title);
-	}
-
+/**
+ * Copyright (c) 2016 committers of YAKINDU 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.examples.wizard.service;
+
+import java.io.File;
+import java.text.Collator;
+import java.util.Arrays;
+
+/**
+ * 
+ * @author t00manysecretss
+ * 
+ */
+public class ExampleData implements Comparable<ExampleData> {
+
+	private static final String PRO_EXAMPLE = "professional";
+	private static final String LABS_EXAMPLE = "labs";
+	private String id;
+	private String title;
+	private String[] category;
+	private String description;
+	private String[] images;
+	private File projectDir;
+
+	public ExampleData(String category[], String id, String title, String description, String[] images) {
+		this.category = category;
+		this.id = id;
+		this.title = title;
+		this.description = description;
+		this.images = images;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public String[] getCategory() {
+		return category;
+	}
+
+	public void setCategory(String[] category) {
+		this.category = category;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	public String[] getImages() {
+		return images;
+	}
+
+	public String[] getFullImagePathes() {
+		String[] result = new String[images.length];
+		String[] imgs = getImages();
+		for (int i = 0; i < imgs.length; i++) {
+			result[i] = getProjectDir() + File.separator + imgs[i];
+		}
+		return result;
+	}
+
+	public void setImages(String[] images) {
+		this.images = images;
+	}
+
+	public File getProjectDir() {
+		return projectDir;
+	}
+
+	public void setProjectDir(File projectDir) {
+		this.projectDir = projectDir;
+	}
+
+	public boolean isProfessional() {
+		return Arrays.asList(getCategory()).contains(PRO_EXAMPLE);
+	}
+	
+	public boolean isLabs() {
+		return Arrays.asList(getCategory()).contains(LABS_EXAMPLE);
+	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((description == null) ? 0 : description.hashCode());
+		result = prime * result + ((category == null) ? 0 : category.hashCode());
+		result = prime * result + ((id == null) ? 0 : id.hashCode());
+		result = prime * result + Arrays.hashCode(images);
+		result = prime * result + ((projectDir == null) ? 0 : projectDir.hashCode());
+		result = prime * result + ((title == null) ? 0 : title.hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		ExampleData other = (ExampleData) obj;
+		if (description == null) {
+			if (other.description != null)
+				return false;
+		} else if (!description.equals(other.description))
+			return false;
+		if (category == null) {
+			if (other.category != null)
+				return false;
+		} else if (!category.equals(other.category))
+			return false;
+		if (id == null) {
+			if (other.id != null)
+				return false;
+		} else if (!id.equals(other.id))
+			return false;
+		if (!Arrays.equals(images, other.images))
+			return false;
+		if (projectDir == null) {
+			if (other.projectDir != null)
+				return false;
+		} else if (!projectDir.equals(other.projectDir))
+			return false;
+		if (title == null) {
+			if (other.title != null)
+				return false;
+		} else if (!title.equals(other.title))
+			return false;
+		return true;
+	}
+
+	@Override
+	public int compareTo(ExampleData other) {
+		return Collator.getInstance().compare(this.title, other.title);
+	}
+
 }

二進制
plugins/org.yakindu.sct.ui.editor/icons/obj16/logolabs-16.png


+ 2 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/StatechartImages.java

@@ -25,6 +25,8 @@ public enum StatechartImages {
 	LOGO("icons/obj16/logo-16.png"),
 
 	PRO_LOGO("icons/obj16/logopro-16.png"),
+	
+	LABS_LOGO("icons/obj16/logolabs-16.png"),
 
 	PRO_EDITION("images/pro.png"),