Commit a51f5ab3 authored by Simon Barner's avatar Simon Barner
Browse files

Merge branch 'master' of https://git.fortiss.org/af3/kernel.git into 3396-developer_documentation

parents 80676a2e bd502046
AnnotationLabelProvider.java ddebfc2bf2c8306884eb748c2c649ff0fe9c3d21 GREEN
CheckBoxLabelProvider.java 44d1e8394703802f14041a058eae89a70501792c GREEN
CheckBoxLabelProvider.java 83f7216dfc05400c5b96aeba8c1add6a02f0eac5 GREEN
ElementCommentLabelProvider.java 76aa6e9b930ce5680607852fd776172942c89ce5 GREEN
ElementLabelProviderBase.java f33502f73033ebdf30316df627e8a9c87e7d1b28 GREEN
ElementNameLabelProvider.java 897296ac8318b6dfdea9c50fc73aaeea23c2fffa GREEN
......
......@@ -14,6 +14,8 @@
*******************************************************************************/
package org.fortiss.tooling.base.ui.annotation.labelprovider;
import static org.fortiss.tooling.base.utils.SystemUtils.isMacOSXPlatform;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewer;
......@@ -46,6 +48,12 @@ public class CheckBoxLabelProvider extends AnnotationLabelProvider {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
// See #2443
if(isMacOSXPlatform() && element instanceof AnnotationEntry &&
((AnnotationEntry)element).canEdit(clazz)) {
return isChecked(element) ? "[X]" : "[ ]";
}
return null;
}
......
......@@ -3,6 +3,7 @@ ActionUtils.java f16dd179005f48c747d2c9cf250b05e7225495cf GREEN
ConstraintsBaseUIUtils.java 50c26b90a6ebe6c7f7861092dac5ebc1f3fc0ce3 GREEN
DragAndDropBaseUtils.java 4308b2151a7075adeb4f7e7246859d421150415b GREEN
EllipseLayoutUIUtils.java 271e287f1e5befb03a9d115a98e22453056521e0 GREEN
FontUtils.java a167a05bdaa8da9853705cc5134f30f6d81bc9f2 GREEN
GCStateManager.java 983973a92376b5c757c1253b32e33d0666ccdf7b GREEN
LayoutDataUIUtils.java 8034bbb9f595092f56807525abcbf23fd5d01428 GREEN
PropertiesViewUtils.java d345b4501c4092228edf1c98e0189317d53aaf22 GREEN
......
......@@ -13,7 +13,11 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.util;
package org.fortiss.tooling.base.ui.utils;
import static org.fortiss.tooling.base.utils.SystemUtils.isLinuxPlatform;
import static org.fortiss.tooling.base.utils.SystemUtils.isMacOSXPlatform;
import static org.fortiss.tooling.base.utils.SystemUtils.isWindowsPlatform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
......@@ -38,9 +42,25 @@ public class FontUtils {
public static FontData VERDANA_16PT = new FontData("Verdana", 16, SWT.NORMAL);
/** Verdana 14pt font. */
public static FontData VERDANA_18PT = new FontData("Verdana", 18, SWT.NORMAL);
/** "Code" 11pt font. */
public static FontData CODEFONT_11PT = createCodeFontData(11);
/** Creates a {@link Font} from the given {@link FontData}, which MUST be disposed after use. */
public static Font createFont(FontData fontData) {
return new Font(Display.getCurrent(), fontData);
}
/** Returns the {@link FontData} used to represent code (OS specific). */
private static FontData createCodeFontData(int height) {
String font = "Courier";
if(isMacOSXPlatform()) {
font = "Monaco";
} else if(isWindowsPlatform()) {
font = "Consolas";
} else if(isLinuxPlatform()) {
font = "Monospace";
}
return new FontData(font, height, SWT.NORMAL);
}
}
AbstractIntegerSpinnerEditingSupport.java 7391e5b0d8e10baf5ab2c7f9543ed732a23bbd9d GREEN
CheckBoxEditingSupport.java 173a63ee86dc396946ddb625a41d48ffad23982f GREEN
CheckBoxLabelProvider.java f810475dbf986b1f33e5b2b13657e52ca0cfd27e GREEN
CheckBoxLabelProvider.java 4eb2a54a17225da5a0f4f3a4212cde0c23d50d11 GREEN
IconNameLabelProvider.java f1700e0c8a86dfe6b10945ce84c2ac935ceab8e7 GREEN
......@@ -17,6 +17,7 @@ package org.fortiss.tooling.base.ui.viewers;
import static org.eclipse.core.runtime.Platform.getBundle;
import static org.eclipse.jface.resource.JFaceResources.getImageRegistry;
import static org.fortiss.tooling.base.utils.SystemUtils.isMacOSXPlatform;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.resource.JFaceResources;
......@@ -118,6 +119,10 @@ public abstract class CheckBoxLabelProvider extends ColumnLabelProvider {
* @return {@link Image} representing the checkbox.
*/
public static Image getImage(boolean checked, boolean enabled) {
// See #2443
if(isMacOSXPlatform()) {
return null;
}
ImageRegistry imgReg = getImageRegistry();
if(imgReg.getDescriptor(CHECKED_KEY) == null) {
imgReg.put(UNCHECKED_KEY, makeShot(false, true));
......@@ -142,6 +147,10 @@ public abstract class CheckBoxLabelProvider extends ColumnLabelProvider {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
// See #2443
if(isMacOSXPlatform() && isEnabled(element)) {
return isChecked(element) ? "[X]" : "[ ]";
}
return null;
}
......
......@@ -34,9 +34,6 @@
</extension>
<extension point="org.fortiss.tooling.kernel.migrationProvider">
<migrationProvider migrationProvider="org.fortiss.tooling.base.migration.IDMigrationProvider">
<objectClass objectClass="org.fortiss.tooling.kernel.extension.data.ITopLevelElement"/>
</migrationProvider>
<migrationProvider migrationProvider="org.fortiss.tooling.base.migration.RemoveDuplicatedAnnotationsMigrationProvider">
<objectClass objectClass="org.fortiss.tooling.kernel.extension.data.ITopLevelElement"/>
</migrationProvider>
......
IDMigrationProvider.java fa145250ce031ab8e635db290b12cd6be2bda75c GREEN
RemoveDuplicatedAnnotationsMigrationProvider.java 5d7689066a577110dbdf84b5c81372b1df2a51c6 GREEN
RemoveOutdatedAnnotationInstanceMigrationProvider.java 29c29f2bb7515cad1de45a30ffc185001b47a016 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2013 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.migration;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.fixMissingIDs;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.hasMissingIDs;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.fortiss.tooling.kernel.extension.IMigrationProvider;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
/**
* {@link IDMigrationProvider} that - if required - adds missing IDs to a model.
*
* @author Shaka
*/
public class IDMigrationProvider implements IMigrationProvider {
/** {@inheritDoc} */
@Override
public boolean needMigration(ITopLevelElement modelElement,
Map<EObject, AnyType> unknownFeatures) {
// if the id of model element is 0
if(modelElement != null) {
EObject rootElement = modelElement.getRootModelElement();
return (rootElement != null) && hasMissingIDs(rootElement);
}
return false;
}
/** {@inheritDoc} */
@Override
public void migrate(ITopLevelElement modelElement, Map<EObject, AnyType> unknownFeatures) {
fixMissingIDs(modelElement);
}
}
......@@ -13,6 +13,6 @@ PointUtils.java b21c92cc8e80ece9d87ede8a750f4de314379743 GREEN
PointsUtils.java bad69811c59004948929f6a57edd5a79c0bf8643 GREEN
RectangleLayoutUtils.java cdd61d162761da7f3e1d3512264135b9b0d564ff GREEN
SnapToGridUtils.java 413785d7a8655db31a129b6f821e1d5f859aa726 GREEN
SystemUtils.java b36590c6934413cd2408de1321af5254dc263e11 GREEN
SystemUtils.java f7893a7db34a994534608bcbd7f214a701c5cf55 GREEN
VisualizationModelElementFactory.java 18e67450ee4cf4a03dc88a10becb0fb6ce4c1bad GREEN
ZoomUtils.java a339613fde18281bed3b55b529a053d348545bc7 GREEN
......@@ -15,16 +15,82 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.utils;
import static java.io.File.separator;
import static java.lang.System.getProperty;
import static java.util.UUID.randomUUID;
/**
* Utility functions that deal with the underlying system.
*
* @author ratiu
* @author ratiu, barner
*/
public class SystemUtils {
/** Returns true if we are in a Windows system. */
public static boolean isWindowsOperatingSystem() {
return System.getProperty("os.name").startsWith("Windows");
/** Cache for {@link #isWindowsPlatform()}. */
private static Boolean isWindowsPlatform = null;
/** Cache for {@link #isLinuxPlatform()}. */
private static Boolean isLinuxPlatform = null;
/** Cache for {@link #isMacOSXPlatform()}. */
private static Boolean isMacOSXPlatform = null;
/** Cache for {@link #isVm64BitArch()}. */
private static Boolean isVm64BitArch;
/** Cache for {@link #isOs64BitArch()}. */
private static Boolean isOs64BitArch;
/** Predicate if the current platform is Windows. */
public static boolean isWindowsPlatform() {
if(isWindowsPlatform != null) {
return isWindowsPlatform;
}
String osName = System.getProperty("os.name");
isWindowsPlatform = osName != null && osName.contains("Windows");
return isWindowsPlatform;
}
/** Predicate if the current platform is Linux. */
public static boolean isLinuxPlatform() {
if(isLinuxPlatform != null) {
return isLinuxPlatform;
}
String osName = System.getProperty("os.name");
isLinuxPlatform = osName != null && osName.contains("Linux");
return isLinuxPlatform;
}
/** Predicate if the current platform is Mac OS X. */
public static boolean isMacOSXPlatform() {
if(isMacOSXPlatform != null) {
return isMacOSXPlatform;
}
String osName = System.getProperty("os.name");
isMacOSXPlatform = osName != null && osName.contains("Mac OS X");
return isMacOSXPlatform;
}
/** Predicate if the current <b>Java VM</b> architecture is 64 bit. */
public static boolean isVm64BitArch() {
if(isVm64BitArch != null) {
return isVm64BitArch;
}
String osArch = System.getProperty("os.arch");
isVm64BitArch = osArch != null && osArch.contains("64");
return isVm64BitArch;
}
/** Predicate if the current <b>OS</b> architecture is 64 bit. */
public static boolean isOs64BitArch() {
if(isOs64BitArch != null) {
return isOs64BitArch;
}
String progFilesX86 = System.getenv("ProgramFiles(x86)");
isOs64BitArch = isWindowsPlatform() ? progFilesX86 != null : isVm64BitArch();
return isOs64BitArch;
}
/**
......@@ -32,7 +98,7 @@ public class SystemUtils {
* interpreted, then an empty string is returned.
*/
public static String interpretProcessExitValues(int exitValue) {
if(!isWindowsOperatingSystem()) {
if(!isWindowsPlatform()) {
switch(exitValue) {
case 126:
return "Command not found";
......@@ -42,4 +108,33 @@ public class SystemUtils {
}
return "";
}
/** Returns the path to the system's temporary directory. */
public static String getSystemTempDirPath() {
return getTempDirPath(false, null);
}
/**
* Returns the path to a directory in the system's temporary directory that follows the pattern<br>
* {@code <SYS_TEMP_DIR>[/UNIQUE_DIR][/SUB_DIR]}
*
* @param unique
* Flag if a unique sub-directory should be appended to the path of the system's
* temporary directory.
* @param subdir
* Sub-directory within system's temporary directory (may be {@code null}).
* @return Path to a directory in the system's temporary directory.
*/
public static String getTempDirPath(boolean unique, String subdir) {
String tmpDir = getProperty("java.io.tmpdir");
if(unique) {
tmpDir += separator + randomUUID();
}
if(subdir != null) {
tmpDir += separator + subdir;
}
return tmpDir;
}
}
ToolingGraphicsGLUIActivator.java 86df10a01835d65709fb655622a1feb2b1a44948 GREEN
ToolingGraphicsGLUIActivator.java 1775f5ee6932438fb7fe6cf15279a7595fdedb53 GREEN
......@@ -17,6 +17,7 @@ package org.fortiss.tooling.graphicsGL.ui;
import static java.lang.System.mapLibraryName;
import static org.eclipse.core.runtime.FileLocator.toFileURL;
import static org.fortiss.tooling.base.utils.SystemUtils.isOs64BitArch;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
......@@ -46,12 +47,7 @@ public class ToolingGraphicsGLUIActivator extends AbstractUIPlugin {
System.out.println(" Preloading native LWJGL libraries.");
boolean is64bit;
if(System.getProperty("os.name").contains("Windows")) {
is64bit = (System.getenv("ProgramFiles(x86)") != null);
} else {
is64bit = (System.getProperty("os.arch").indexOf("64") != -1);
}
boolean is64bit = isOs64BitArch();
// preload JEMALLOC
String jemallocLibPath = loadPluginLocalLibrary(getBundle(), "jemalloc", is64bit);
......
AutoUndoCommandStack.java 6aa645a9ed6e6547539c376fda97284928c4f9d4 GREEN
EMFTransactionalCommand.java ba4b5bead9768b6ce6c955b9238cd96cb722533c GREEN
EclipseResourceStorageService.java 1b9722e31a5ec33e4c3f7bb171fc2ce587729bf8 GREEN
ModelContext.java 58e41785101a92624e60329b5bf8046466a49d33 GREEN
ModelContext.java 85ede185d4b232221a96d0bf37a4c676b105dc00 GREEN
NonDirtyingEMFTransactionalCommand.java ec5f282603891096b09f2628155dd27e3a21c588 GREEN
......@@ -15,10 +15,13 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.internal.storage.eclipse;
import static java.lang.Math.max;
import static org.eclipse.emf.common.util.URI.createPlatformResourceURI;
import static org.eclipse.emf.ecore.util.EcoreUtil.resolveAll;
import static org.fortiss.tooling.kernel.utils.EMFResourceUtils.buildOptionsMap;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.warning;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.generateMissingIDs;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
......@@ -36,6 +39,7 @@ import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.CommandStack;
......@@ -110,7 +114,7 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
editingDomain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
rset = editingDomain.getResourceSet();
URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
URI uri = createPlatformResourceURI(file.getFullPath().toString(), true);
resource = getResourceSet().createResource(uri);
resource.load(buildOptionsMap());
......@@ -201,29 +205,29 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
// which is why special care must be taken to ensure uniqueness.
if(ids.contains(id)) {
hadDuplicates = true;
runAsCommand(new Runnable() {
@Override
public void run() {
element.setId(0);
}
runAsNonDirtyingCommand(() -> {
element.setId(0);
});
} else {
ids.add(id);
}
}
maxId = Math.max(maxId, id);
maxId = max(maxId, id);
}
}
maxId = Math.max(0, maxId);
maxId = max(0, maxId);
if(hadMissing || hadDuplicates) {
runAsCommand(new Runnable() {
@Override
public void run() {
maxId = UniqueIDUtils.generateMissingIDs(getRootModelElement(), maxId);
}
runAsNonDirtyingCommand(() -> {
maxId = generateMissingIDs(getRootModelElement(), maxId);
});
try {
doSave(new NullProgressMonitor());
} catch(IOException | CoreException e) {
error(ToolingKernelActivator.getDefault(),
"Error saving model file when fixing missing/duplicate IDs.", e);
}
}
if(hadDuplicates) {
......
......@@ -11,4 +11,4 @@ LoggingUtils.java a982f7c3371e72feb8658510b5b0358876281a12 GREEN
PrototypesUtils.java ec75bed75cfc5103f1f38e3a29df86f729428775 GREEN
ResourceUtils.java 5d8f55b3b22a8d963a26ae4a83b4228e2a03d963 GREEN
TransformationUtils.java ef1f2346a7e31059fe6a48dff49d247809d38dcd GREEN
UniqueIDUtils.java 99cf0934ee27a95f4b6edbc251e6ff24e5d1d7f7 GREEN
UniqueIDUtils.java c520d053a6530a490431f7acc3cda1a2f8907281 GREEN
......@@ -259,42 +259,24 @@ public class UniqueIDUtils {
return false;
}
/**
* Generates all missing IDs of the given model.
*
* @param modelElement
* top level element
*/
public static void fixMissingIDs(final ITopLevelElement modelElement) {
final int maxID = getLargestID(modelElement.getRootModelElement());
if(maxID > 0) {
modelElement.runAsCommand(() -> {
generateMissingIDs(modelElement.getRootModelElement(), maxID);
});
}
}
/**
* Generates all missing IDs of the given sub-model.
*
* @param object
* The sub-model element for which missing IDs should be prepared
* Sub-model element for which missing IDs should be prepared
* @param existingModel
* the existing model to be considered for used IDs if object
* already contains IDs > 0
* Any element in an existing model to be considered for used IDs.
* If this model does not contain any IDs <> 0, this method has no effect.
*/
public static void fixMissingIDs(EObject object, EObject existingModel) {
EObject root = existingModel;
while(root.eContainer() != null) {
root = root.eContainer();
}
ITopLevelElement topLevelElement =
IPersistencyService.getInstance().getTopLevelElementFor(existingModel);
final int maxID = getLargestID(root);
if(maxID > 0) {
topLevelElement.runAsCommand(() -> {
generateMissingIDs(object, maxID);
});
generateMissingIDs(object, maxID);
}
}
}
......@@ -3,6 +3,6 @@ ChartStyle.java b2c76a10141ebe9a083d5456bd9e5ef61f472500 GREEN
ColorStyleBase.java b8e824b55490b30507b8d38acf10bc61daf1fa00 GREEN
DataSeriesStyle.java a7bda5ba4e12133ea20edda627e41560b3679641 GREEN
FillStyle.java 36e54f1ecb31836a7c7a821ddf0432264349bd83 GREEN
FontStyle.java b180fc768372ae374f17034cbb91fe3891fd569f GREEN
FontStyle.java 012dfcddfd85159ba6045141df0762289fb70d6f GREEN
LegendStyle.java 39a10d789aeac41114b8b43e7e6790543cb2f618 GREEN
LineStyle.java bc3df608b46c9d2fa367cf75465961389ab4491f GREEN
......@@ -15,12 +15,12 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.style;
import static org.fortiss.tooling.spiderchart.util.FontUtils.VERDANA_10PT;
import static org.fortiss.tooling.spiderchart.util.FontUtils.VERDANA_12PT;
import static org.fortiss.tooling.spiderchart.util.FontUtils.VERDANA_14PT;
import static org.fortiss.tooling.spiderchart.util.FontUtils.VERDANA_16PT;
import static org.fortiss.tooling.spiderchart.util.FontUtils.VERDANA_18PT;
import static org.fortiss.tooling.spiderchart.util.FontUtils.VERDANA_8PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_10PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_12PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_14PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_16PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_18PT;
import static org.fortiss.tooling.base.ui.utils.FontUtils.VERDANA_8PT;
import static org.fortiss.tooling.spiderchart.util.RGBColorUtils.BLACK;
import org.eclipse.swt.graphics.FontData;
......
AxisUtils.java 22f9dae3ee0b9bb4daef19977f2d327dc4b10f8f GREEN
FontUtils.java 759aeeea8de17e5d555ecd81592b9897dd36bc37 GREEN
RGBColorUtils.java 2fc319ab0bc3d898f7c68db324cded3ddcd45f70 GREEN
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment