From 1460904fd3c193ffaf809913b2983a400fce9d94 Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Thu, 19 Jul 2012 10:22:04 +0200 Subject: Fix line endings in master (dos2unix) --- .../.settings/org.eclipse.core.resources.prefs | 6 +- plugins/org.eclipse.emf.cdo.dawn.ui/contexts.xml | 44 +- plugins/org.eclipse.emf.cdo.dawn.ui/copyright.txt | 14 +- .../org.eclipse.emf.cdo.dawn.ui/plugin.properties | 22 +- plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml | 250 +++---- .../emf/cdo/dawn/internal/ui/bundle/OM.java | 90 +-- .../emf/cdo/dawn/ui/DawnColorConstants.java | 66 +- .../eclipse/emf/cdo/dawn/ui/DawnEditorInput.java | 110 +-- .../eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java | 196 ++--- ...lectionViewerAdapterFactoryContentProvider.java | 78 +- .../eclipse/emf/cdo/dawn/ui/IDawnEditorInput.java | 42 +- .../CDOResourceNodeChooserComposite.java | 832 ++++++++++----------- .../composites/CDOResourceNodeSelectionWidget.java | 294 ++++---- .../cdo/dawn/ui/handlers/LockObjectsHandler.java | 62 +- .../emf/cdo/dawn/ui/handlers/SelectionHandler.java | 90 +-- .../cdo/dawn/ui/handlers/SolveConflictHandler.java | 120 +-- .../cdo/dawn/ui/handlers/UnLockObjectsHandler.java | 62 +- .../dawn/ui/helper/EditorDescriptionHelper.java | 192 ++--- .../emf/cdo/dawn/ui/icons/DawnIconRegistry.java | 206 ++--- .../eclipse/emf/cdo/dawn/ui/messages/Messages.java | 98 +-- .../emf/cdo/dawn/ui/messages/messages.properties | 36 +- .../ui/stylizer/DawnDefaultElementStylizer.java | 168 ++--- .../ui/stylizer/DawnElementStylizerRegistry.java | 324 ++++---- .../emf/cdo/dawn/ui/views/DawnItemProvider.java | 152 ++-- .../dawn/ui/views/DawnWizardPageItemProvider.java | 172 ++--- .../DawnCreateNewDiagramResourceWizardPage.java | 80 +- .../wizards/DawnCreateNewResourceWizardPage.java | 370 ++++----- .../dialogs/CDOResourceNodeSelectionDialog.java | 188 ++--- 28 files changed, 2182 insertions(+), 2182 deletions(-) (limited to 'plugins/org.eclipse.emf.cdo.dawn.ui') diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.emf.cdo.dawn.ui/.settings/org.eclipse.core.resources.prefs index 196cfa85d5..aa2771cd19 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/.settings/org.eclipse.core.resources.prefs +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,3 @@ -#Mon Jul 04 13:05:14 CEST 2011 -eclipse.preferences.version=1 -encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8 +#Mon Jul 04 13:05:14 CEST 2011 +eclipse.preferences.version=1 +encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8 diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/contexts.xml b/plugins/org.eclipse.emf.cdo.dawn.ui/contexts.xml index 73d56a9429..85dd321200 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/contexts.xml +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/contexts.xml @@ -1,22 +1,22 @@ - - - - This is the context help for the sample view with a tree viewer. It was generated by a PDE template. - - - - - - - - - + + + + This is the context help for the sample view with a tree viewer. It was generated by a PDE template. + + + + + + + + + diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/copyright.txt b/plugins/org.eclipse.emf.cdo.dawn.ui/copyright.txt index 9cbb3ba084..cea141de92 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/copyright.txt +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/copyright.txt @@ -1,8 +1,8 @@ -Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: +Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: Martin Fluegge - initial API and implementation \ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.properties b/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.properties index acd46c75ba..f0a0e8c0a0 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.properties @@ -1,11 +1,11 @@ -# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: -# Martin Fluegge - initial API and implementation - -pluginName = CDO Dawn UI -providerName = Eclipse Modeling Project +# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: +# Martin Fluegge - initial API and implementation + +pluginName = CDO Dawn UI +providerName = Eclipse Modeling Project diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml index 058568fb25..ad3c42151f 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml @@ -1,125 +1,125 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/internal/ui/bundle/OM.java index 5d5215c458..3a47a37930 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/internal/ui/bundle/OM.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/internal/ui/bundle/OM.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.internal.ui.bundle; - -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.OSGiActivator; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.trace.OMTracer; - -/** - * @author Martin Fluegge - */ -public abstract class OM -{ - public static final String BUNDLE_ID = "org.eclipse.emf.cdo.dawn.ui"; //$NON-NLS-1$ - - public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); - - public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_OBJECT = DEBUG.tracer("object"); //$NON-NLS-1$ - - public static final OMLogger LOG = BUNDLE.logger(); - - /** - * @author Martin Fluegge - * @since 1.0 - */ - public static final class Activator extends OSGiActivator - { - public Activator() - { - super(BUNDLE); - } - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.internal.ui.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OSGiActivator; +import org.eclipse.net4j.util.om.log.OMLogger; +import org.eclipse.net4j.util.om.trace.OMTracer; + +/** + * @author Martin Fluegge + */ +public abstract class OM +{ + public static final String BUNDLE_ID = "org.eclipse.emf.cdo.dawn.ui"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_OBJECT = DEBUG.tracer("object"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + /** + * @author Martin Fluegge + * @since 1.0 + */ + public static final class Activator extends OSGiActivator + { + public Activator() + { + super(BUNDLE); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnColorConstants.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnColorConstants.java index d8a82e937e..35cbb7c03b 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnColorConstants.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnColorConstants.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.swt.graphics.Color; - -/** - * @author Martin Fluegge - * @since 2.0 - */ -public class DawnColorConstants -{ - public static final Color COLOR_NO_BORDER = new Color(null, 255, 255, 255); - - public static final Color COLOR_LOCKED_REMOTELY = ColorConstants.yellow; - - public static final Color COLOR_LOCKED_LOCALLY = ColorConstants.green; - - public static final Color COLOR_DELETE_CONFLICT = new Color(null, 255, 0, 0); - - public static final Color COLOR_CHANGE_CONFLICT = new Color(null, 0, 0, 255); - - public static final Color COLOR_NO_CONFLICT = new Color(null, 255, 255, 255); -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.swt.graphics.Color; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public class DawnColorConstants +{ + public static final Color COLOR_NO_BORDER = new Color(null, 255, 255, 255); + + public static final Color COLOR_LOCKED_REMOTELY = ColorConstants.yellow; + + public static final Color COLOR_LOCKED_LOCALLY = ColorConstants.green; + + public static final Color COLOR_DELETE_CONFLICT = new Color(null, 255, 0, 0); + + public static final Color COLOR_CHANGE_CONFLICT = new Color(null, 0, 0, 255); + + public static final Color COLOR_NO_CONFLICT = new Color(null, 255, 255, 255); +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnEditorInput.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnEditorInput.java index 91f9780794..f9cc8d8deb 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnEditorInput.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnEditorInput.java @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui; - -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.ui.URIEditorInput; -import org.eclipse.emf.common.util.URI; - -/** - * @author Martin Fluegge - */ -public class DawnEditorInput extends URIEditorInput implements IDawnEditorInput -{ - private CDOResource resource = null; - - public DawnEditorInput(URI uri) - { - super(uri); - } - - public CDOView getView() - { - return getResource().cdoView(); - } - - public boolean isViewOwned() - { - return false; - } - - public String getResourcePath() - { - return getResource().getPath(); - } - - public void setResource(CDOResource resource) - { - this.resource = resource; - } - - public CDOResource getResource() - { - return resource; - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.ui.URIEditorInput; +import org.eclipse.emf.common.util.URI; + +/** + * @author Martin Fluegge + */ +public class DawnEditorInput extends URIEditorInput implements IDawnEditorInput +{ + private CDOResource resource = null; + + public DawnEditorInput(URI uri) + { + super(uri); + } + + public CDOView getView() + { + return getResource().cdoView(); + } + + public boolean isViewOwned() + { + return false; + } + + public String getResourcePath() + { + return getResource().getPath(); + } + + public void setResource(CDOResource resource) + { + this.resource = resource; + } + + public CDOResource getResource() + { + return resource; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java index caea4198b3..5dd6889bda 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer; -import org.eclipse.emf.cdo.dawn.spi.DawnState; -import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry; -import org.eclipse.emf.cdo.ui.CDOLabelProvider; -import org.eclipse.emf.cdo.util.CDOUtil; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; - -/** - * @author Martin Fluegge - * @since 1.0 - */ -public class DawnLabelProvider extends CDOLabelProvider -{ - public DawnLabelProvider(AdapterFactory adapterFactory, CDOView view, TreeViewer viewer) - { - super(adapterFactory, view, viewer); - } - - @Override - public Color getForeground(Object object) - { - // makes sure that the object is adapted - Color foreground = super.getForeground(object); - - DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(object); - - CDOObject cdoObject = CDOUtil.getCDOObject((EObject)object); - if (cdoObject.cdoWriteLock().isLocked()) - { - return stylizer.getForegroundColor(cdoObject, DawnState.LOCKED_LOCALLY); - } - else if (CDOUtil.getCDOObject((EObject)object).cdoWriteLock().isLockedByOthers()) - { - return stylizer.getForegroundColor(cdoObject, DawnState.LOCKED_REMOTELY); - } - // Use default - return foreground; - } - - @Override - public Color getBackground(Object object) - { - // makes sure that the object is adapted - Color background = super.getBackground(object); - - DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(object); - - CDOObject cdoObject = CDOUtil.getCDOObject((EObject)object); - if (cdoObject.cdoWriteLock().isLocked()) - { - return stylizer.getBackgroundColor(cdoObject, DawnState.LOCKED_LOCALLY); - } - else if (CDOUtil.getCDOObject((EObject)object).cdoWriteLock().isLockedByOthers()) - { - return stylizer.getBackgroundColor(cdoObject, DawnState.LOCKED_REMOTELY); - } - // Use default - return background; - } - - @Override - public Image getImage(Object object) - { - DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(object); - - CDOObject cdoObject = CDOUtil.getCDOObject((EObject)object); - if (cdoObject.cdoWriteLock().isLocked()) - { - return stylizer.getImage(cdoObject, DawnState.LOCKED_LOCALLY); - } - else if (CDOUtil.getCDOObject((EObject)object).cdoWriteLock().isLockedByOthers()) - { - return stylizer.getImage(cdoObject, DawnState.LOCKED_REMOTELY); - } - - return super.getImage(object); - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer; +import org.eclipse.emf.cdo.dawn.spi.DawnState; +import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry; +import org.eclipse.emf.cdo.ui.CDOLabelProvider; +import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; + +/** + * @author Martin Fluegge + * @since 1.0 + */ +public class DawnLabelProvider extends CDOLabelProvider +{ + public DawnLabelProvider(AdapterFactory adapterFactory, CDOView view, TreeViewer viewer) + { + super(adapterFactory, view, viewer); + } + + @Override + public Color getForeground(Object object) + { + // makes sure that the object is adapted + Color foreground = super.getForeground(object); + + DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(object); + + CDOObject cdoObject = CDOUtil.getCDOObject((EObject)object); + if (cdoObject.cdoWriteLock().isLocked()) + { + return stylizer.getForegroundColor(cdoObject, DawnState.LOCKED_LOCALLY); + } + else if (CDOUtil.getCDOObject((EObject)object).cdoWriteLock().isLockedByOthers()) + { + return stylizer.getForegroundColor(cdoObject, DawnState.LOCKED_REMOTELY); + } + // Use default + return foreground; + } + + @Override + public Color getBackground(Object object) + { + // makes sure that the object is adapted + Color background = super.getBackground(object); + + DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(object); + + CDOObject cdoObject = CDOUtil.getCDOObject((EObject)object); + if (cdoObject.cdoWriteLock().isLocked()) + { + return stylizer.getBackgroundColor(cdoObject, DawnState.LOCKED_LOCALLY); + } + else if (CDOUtil.getCDOObject((EObject)object).cdoWriteLock().isLockedByOthers()) + { + return stylizer.getBackgroundColor(cdoObject, DawnState.LOCKED_REMOTELY); + } + // Use default + return background; + } + + @Override + public Image getImage(Object object) + { + DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(object); + + CDOObject cdoObject = CDOUtil.getCDOObject((EObject)object); + if (cdoObject.cdoWriteLock().isLocked()) + { + return stylizer.getImage(cdoObject, DawnState.LOCKED_LOCALLY); + } + else if (CDOUtil.getCDOObject((EObject)object).cdoWriteLock().isLockedByOthers()) + { + return stylizer.getImage(cdoObject, DawnState.LOCKED_REMOTELY); + } + + return super.getImage(object); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnSelectionViewerAdapterFactoryContentProvider.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnSelectionViewerAdapterFactoryContentProvider.java index 0e7293e5fe..ba420fad87 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnSelectionViewerAdapterFactoryContentProvider.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnSelectionViewerAdapterFactoryContentProvider.java @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui; - -import org.eclipse.emf.cdo.eresource.CDOResource; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; - -/** - * @author Martin Fluegge - * @since 1.0 - */ -public class DawnSelectionViewerAdapterFactoryContentProvider extends AdapterFactoryContentProvider -{ - private final CDOResource cdoResource; - - public DawnSelectionViewerAdapterFactoryContentProvider(AdapterFactory adapterFactory, CDOResource cdoResource) - { - super(adapterFactory); - this.cdoResource = cdoResource; - } - - @Override - public Object[] getElements(Object object) - { - Object[] ret = new Object[1]; - ret[0] = cdoResource; - return ret; - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui; + +import org.eclipse.emf.cdo.eresource.CDOResource; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; + +/** + * @author Martin Fluegge + * @since 1.0 + */ +public class DawnSelectionViewerAdapterFactoryContentProvider extends AdapterFactoryContentProvider +{ + private final CDOResource cdoResource; + + public DawnSelectionViewerAdapterFactoryContentProvider(AdapterFactory adapterFactory, CDOResource cdoResource) + { + super(adapterFactory); + this.cdoResource = cdoResource; + } + + @Override + public Object[] getElements(Object object) + { + Object[] ret = new Object[1]; + ret[0] = cdoResource; + return ret; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/IDawnEditorInput.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/IDawnEditorInput.java index bc1a7f34e6..99d031e179 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/IDawnEditorInput.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/IDawnEditorInput.java @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui; - -import org.eclipse.emf.cdo.ui.CDOEditorInput; - -/** - * @author Martin Fluegge - * @since 2.0 - */ -public interface IDawnEditorInput extends CDOEditorInput -{ -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui; + +import org.eclipse.emf.cdo.ui.CDOEditorInput; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public interface IDawnEditorInput extends CDOEditorInput +{ +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/composites/CDOResourceNodeChooserComposite.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/composites/CDOResourceNodeChooserComposite.java index 6cb176bff0..71c42dbadc 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/composites/CDOResourceNodeChooserComposite.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/composites/CDOResourceNodeChooserComposite.java @@ -1,416 +1,416 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.composites; - -import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants; -import org.eclipse.emf.cdo.dawn.ui.messages.Messages; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.eresource.CDOResourceNode; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import java.util.Date; - -/** - * @author Martin Fluegge - * @since 1.0 - */ -public class CDOResourceNodeChooserComposite extends Composite -{ - private final String fileExtension; - - protected Text resourcePathComposite; - - protected Text resourceNameComposite; - - private String resourceNamePrefix = "default"; //$NON-NLS-1$ - - protected CDOResourceNodeSelectionWidget selectCDOResourceNodeComposite; - - private final CDOView view; - - private ResourceChooserValidator validator; - - public CDOResourceNodeChooserComposite(Composite parent, int style, String fileExtension, CDOView view) - { - super(parent, style); - this.fileExtension = fileExtension; - this.view = view; - init(); - setValidator(new ResourceChooserValidator()); - } - - private void createLayout() - { - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginWidth = 0; - setLayout(layout); - } - - public void setResourcePath(String resourcePath) - { - resourcePathComposite.setText(resourcePath); - } - - public void setResourceName(String resourceNamePrefix) - { - resourceNameComposite.setText(resourceNamePrefix); - } - - protected void init() - { - createLayout(); - createResourcePathInput(); - - createResourceSelectionComposite(); - - createResourceInput(); - } - - public String getResourceName() - { - return resourceNameComposite.getText(); - } - - public String getResourcePath() - { - return resourcePathComposite.getText(); - } - - private void createResourceSelectionComposite() - { - selectCDOResourceNodeComposite = new CDOResourceNodeSelectionWidget(this, SWT.NONE); - - GridData gd = new GridData(GridData.FILL_BOTH); - - selectCDOResourceNodeComposite.setLayoutData(gd); - - selectCDOResourceNodeComposite.addSelectionChangedListener(new ISelectionChangedListener() - { - public void selectionChanged(SelectionChangedEvent event) - { - if (event.getSelection().isEmpty()) - { - resourceNameComposite.setText(""); //$NON-NLS-1$ - return; - } - - if (event.getSelection() instanceof IStructuredSelection) - { - IStructuredSelection selection = (IStructuredSelection)event.getSelection(); - Object element = selection.getFirstElement(); - if (element instanceof CDOResource) - { - String resourceName = ((CDOResource)element).getName(); - resourcePathComposite.setText(((CDOResource)element).getPath().replace(resourceName, "")); //$NON-NLS-1$ - resourceNameComposite.setText(resourceName); - } - else if (element instanceof CDOResourceNode) - { - resourcePathComposite.setText(((CDOResourceNode)element).getPath()); - } - } - - getValidator().validate(); - } - }); - } - - private void createResourceInput() - { - Composite nameGroup = new Composite(this, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = 0; - nameGroup.setLayout(layout); - nameGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); - - Label label1 = new Label(nameGroup, SWT.NONE); - label1.setText(Messages.DawnCreateNewResourceWizardPage_6); - - resourceNameComposite = new Text(nameGroup, SWT.BORDER | SWT.SINGLE); - resourceNameComposite.setText(getDefaultName() + "." + fileExtension); //$NON-NLS-1$ - resourceNameComposite.addKeyListener(new KeyListener() - { - public void keyPressed(KeyEvent e) - { - } - - public void keyReleased(KeyEvent e) - { - getValidator().validate(); - } - }); - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - resourceNameComposite.setLayoutData(gd); - } - - private GridData createResourcePathInput() - { - Label resourcePathLabel = new Label(this, SWT.NULL); - resourcePathLabel.setText(Messages.DawnCreateNewResourceWizardPage_8); - - resourcePathComposite = new Text(this, SWT.BORDER | SWT.SINGLE); - resourcePathComposite.setText(""); //$NON-NLS-1$ - resourcePathComposite.addKeyListener(new KeyListener() - { - public void keyPressed(KeyEvent e) - { - } - - public void keyReleased(KeyEvent e) - { - getValidator().validate(); - } - - }); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - resourcePathComposite.setLayoutData(gd); - return gd; - } - - public void createAutomaticResourceName() - { - int i = 2; - while (i < 30 && view.hasResource(getURI().path())) - { - resourceNameComposite.setText(getResourceNamePrefix() + i + "." + fileExtension); //$NON-NLS-1$ - i++; - } - - if (i < 30) - { - return; - } - // if we have tried 30 times to find a new resource name and still not succeeded just add a timestamp to the name - resourceNameComposite.setText(getResourceNamePrefix() + new Date().getTime() + "." + fileExtension); //$NON-NLS-1$ - } - - public URI getURI() - { - String resourcePath = getResourcePath(); - if (resourcePath.length() > 0) - { - if (resourcePath.startsWith("/")) //$NON-NLS-1$ - { - resourcePath = resourcePath.substring(1, resourcePath.length()); - } - if (!resourcePath.endsWith("/")) //$NON-NLS-1$ - { - resourcePath = resourcePath + "/"; //$NON-NLS-1$ - } - } - - String resourceName = getResourceName(); - String authority = PreferenceConstants.getRepositoryName(); - URI uri = URI.createURI("cdo://" + authority + "/" + resourcePath + resourceName); //$NON-NLS-1$ //$NON-NLS-2$ - - return uri; - } - - public String getDefaultName() - { - return getResourceNamePrefix(); - } - - public void showResources(boolean showResources) - { - selectCDOResourceNodeComposite.setShowResources(showResources); - } - - public void setResourceNamePrefix(String resourceNamePrefix) - { - this.resourceNamePrefix = resourceNamePrefix; - } - - public String getResourceNamePrefix() - { - return resourceNamePrefix; - } - - public void setValidator(ResourceChooserValidator validator) - { - this.validator = validator; - } - - public ResourceChooserValidator getValidator() - { - return validator; - } - - /** - * @author Martin Fluegge - */ - public class ResourceChooserValidator - { - public static final int VALIDATION_NONE = 0; - - public static final int VALIDATION_WARN = 1; - - public static final int VALIDATION_ERROR = 2; - - private int resourceValidationType = VALIDATION_ERROR; - - private boolean valid; - - private int messageType = IMessageProvider.NONE; - - private String message; - - private ValidationListener validationListener; - - public ResourceChooserValidator() - { - } - - public void validate() - { - internalValidate(); - if (validationListener != null) - { - validationListener.validationFinished(); - } - } - - private void internalValidate() - { - setValid(true); - - if (getResourceName().length() == 0) - { - setMessage(Messages.DawnCreateNewResourceWizardPage_10, IMessageProvider.ERROR); - setValid(false); - return; - } - - if (!getResourceName().endsWith("." + fileExtension)) - { - setValid(false); - setMessage(Messages.CDOResourceNodeChooserComposite_1 + fileExtension, IMessageProvider.ERROR); - return; - } - - if (view != null && getResourceValidationType() != VALIDATION_NONE) - { - try - { - if (view.hasResource(getURI().path())) - { - if (getResourceValidationType() == VALIDATION_WARN) - { - setMessage(Messages.DawnCreateNewResourceWizardPage_11, IMessageProvider.WARNING); - setMessageType(IMessageProvider.WARNING); - setValid(true); - return; - } - else if (getResourceValidationType() == VALIDATION_ERROR) - { - setMessage(Messages.DawnCreateNewResourceWizardPage_12, IMessageProvider.ERROR); - setValid(false); - setMessageType(IMessageProvider.ERROR); - return; - } - } - } - catch (Exception e) - { - setMessage(e.getMessage()); - setMessageType(IMessageProvider.ERROR); - } - } - if (isValid()) - { - setMessage(null); - setMessageType(IMessageProvider.NONE); - } - } - - private void setMessage(String message, int type) - { - setMessage(message); - setMessageType(type); - } - - public void setValid(boolean valid) - { - this.valid = valid; - } - - public boolean isValid() - { - return valid; - } - - public void setMessage(String message) - { - this.message = message; - } - - public String getMessage() - { - return message; - } - - public void setMessageType(int messageType) - { - this.messageType = messageType; - } - - public int getMessageType() - { - return messageType; - } - - public void setResourceValidationType(int resourceValidationType) - { - this.resourceValidationType = resourceValidationType; - } - - public int getResourceValidationType() - { - return resourceValidationType; - } - - public void setValidationListener(ValidationListener validationListener) - { - this.validationListener = validationListener; - } - - public ValidationListener getValidationListener() - { - return validationListener; - } - } - - /** - * @author Martin Fluegge - */ - public static interface ValidationListener - { - public void validationFinished(); - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.composites; + +import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants; +import org.eclipse.emf.cdo.dawn.ui.messages.Messages; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import java.util.Date; + +/** + * @author Martin Fluegge + * @since 1.0 + */ +public class CDOResourceNodeChooserComposite extends Composite +{ + private final String fileExtension; + + protected Text resourcePathComposite; + + protected Text resourceNameComposite; + + private String resourceNamePrefix = "default"; //$NON-NLS-1$ + + protected CDOResourceNodeSelectionWidget selectCDOResourceNodeComposite; + + private final CDOView view; + + private ResourceChooserValidator validator; + + public CDOResourceNodeChooserComposite(Composite parent, int style, String fileExtension, CDOView view) + { + super(parent, style); + this.fileExtension = fileExtension; + this.view = view; + init(); + setValidator(new ResourceChooserValidator()); + } + + private void createLayout() + { + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + layout.marginWidth = 0; + setLayout(layout); + } + + public void setResourcePath(String resourcePath) + { + resourcePathComposite.setText(resourcePath); + } + + public void setResourceName(String resourceNamePrefix) + { + resourceNameComposite.setText(resourceNamePrefix); + } + + protected void init() + { + createLayout(); + createResourcePathInput(); + + createResourceSelectionComposite(); + + createResourceInput(); + } + + public String getResourceName() + { + return resourceNameComposite.getText(); + } + + public String getResourcePath() + { + return resourcePathComposite.getText(); + } + + private void createResourceSelectionComposite() + { + selectCDOResourceNodeComposite = new CDOResourceNodeSelectionWidget(this, SWT.NONE); + + GridData gd = new GridData(GridData.FILL_BOTH); + + selectCDOResourceNodeComposite.setLayoutData(gd); + + selectCDOResourceNodeComposite.addSelectionChangedListener(new ISelectionChangedListener() + { + public void selectionChanged(SelectionChangedEvent event) + { + if (event.getSelection().isEmpty()) + { + resourceNameComposite.setText(""); //$NON-NLS-1$ + return; + } + + if (event.getSelection() instanceof IStructuredSelection) + { + IStructuredSelection selection = (IStructuredSelection)event.getSelection(); + Object element = selection.getFirstElement(); + if (element instanceof CDOResource) + { + String resourceName = ((CDOResource)element).getName(); + resourcePathComposite.setText(((CDOResource)element).getPath().replace(resourceName, "")); //$NON-NLS-1$ + resourceNameComposite.setText(resourceName); + } + else if (element instanceof CDOResourceNode) + { + resourcePathComposite.setText(((CDOResourceNode)element).getPath()); + } + } + + getValidator().validate(); + } + }); + } + + private void createResourceInput() + { + Composite nameGroup = new Composite(this, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginWidth = 0; + nameGroup.setLayout(layout); + nameGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); + + Label label1 = new Label(nameGroup, SWT.NONE); + label1.setText(Messages.DawnCreateNewResourceWizardPage_6); + + resourceNameComposite = new Text(nameGroup, SWT.BORDER | SWT.SINGLE); + resourceNameComposite.setText(getDefaultName() + "." + fileExtension); //$NON-NLS-1$ + resourceNameComposite.addKeyListener(new KeyListener() + { + public void keyPressed(KeyEvent e) + { + } + + public void keyReleased(KeyEvent e) + { + getValidator().validate(); + } + }); + + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + resourceNameComposite.setLayoutData(gd); + } + + private GridData createResourcePathInput() + { + Label resourcePathLabel = new Label(this, SWT.NULL); + resourcePathLabel.setText(Messages.DawnCreateNewResourceWizardPage_8); + + resourcePathComposite = new Text(this, SWT.BORDER | SWT.SINGLE); + resourcePathComposite.setText(""); //$NON-NLS-1$ + resourcePathComposite.addKeyListener(new KeyListener() + { + public void keyPressed(KeyEvent e) + { + } + + public void keyReleased(KeyEvent e) + { + getValidator().validate(); + } + + }); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + resourcePathComposite.setLayoutData(gd); + return gd; + } + + public void createAutomaticResourceName() + { + int i = 2; + while (i < 30 && view.hasResource(getURI().path())) + { + resourceNameComposite.setText(getResourceNamePrefix() + i + "." + fileExtension); //$NON-NLS-1$ + i++; + } + + if (i < 30) + { + return; + } + // if we have tried 30 times to find a new resource name and still not succeeded just add a timestamp to the name + resourceNameComposite.setText(getResourceNamePrefix() + new Date().getTime() + "." + fileExtension); //$NON-NLS-1$ + } + + public URI getURI() + { + String resourcePath = getResourcePath(); + if (resourcePath.length() > 0) + { + if (resourcePath.startsWith("/")) //$NON-NLS-1$ + { + resourcePath = resourcePath.substring(1, resourcePath.length()); + } + if (!resourcePath.endsWith("/")) //$NON-NLS-1$ + { + resourcePath = resourcePath + "/"; //$NON-NLS-1$ + } + } + + String resourceName = getResourceName(); + String authority = PreferenceConstants.getRepositoryName(); + URI uri = URI.createURI("cdo://" + authority + "/" + resourcePath + resourceName); //$NON-NLS-1$ //$NON-NLS-2$ + + return uri; + } + + public String getDefaultName() + { + return getResourceNamePrefix(); + } + + public void showResources(boolean showResources) + { + selectCDOResourceNodeComposite.setShowResources(showResources); + } + + public void setResourceNamePrefix(String resourceNamePrefix) + { + this.resourceNamePrefix = resourceNamePrefix; + } + + public String getResourceNamePrefix() + { + return resourceNamePrefix; + } + + public void setValidator(ResourceChooserValidator validator) + { + this.validator = validator; + } + + public ResourceChooserValidator getValidator() + { + return validator; + } + + /** + * @author Martin Fluegge + */ + public class ResourceChooserValidator + { + public static final int VALIDATION_NONE = 0; + + public static final int VALIDATION_WARN = 1; + + public static final int VALIDATION_ERROR = 2; + + private int resourceValidationType = VALIDATION_ERROR; + + private boolean valid; + + private int messageType = IMessageProvider.NONE; + + private String message; + + private ValidationListener validationListener; + + public ResourceChooserValidator() + { + } + + public void validate() + { + internalValidate(); + if (validationListener != null) + { + validationListener.validationFinished(); + } + } + + private void internalValidate() + { + setValid(true); + + if (getResourceName().length() == 0) + { + setMessage(Messages.DawnCreateNewResourceWizardPage_10, IMessageProvider.ERROR); + setValid(false); + return; + } + + if (!getResourceName().endsWith("." + fileExtension)) + { + setValid(false); + setMessage(Messages.CDOResourceNodeChooserComposite_1 + fileExtension, IMessageProvider.ERROR); + return; + } + + if (view != null && getResourceValidationType() != VALIDATION_NONE) + { + try + { + if (view.hasResource(getURI().path())) + { + if (getResourceValidationType() == VALIDATION_WARN) + { + setMessage(Messages.DawnCreateNewResourceWizardPage_11, IMessageProvider.WARNING); + setMessageType(IMessageProvider.WARNING); + setValid(true); + return; + } + else if (getResourceValidationType() == VALIDATION_ERROR) + { + setMessage(Messages.DawnCreateNewResourceWizardPage_12, IMessageProvider.ERROR); + setValid(false); + setMessageType(IMessageProvider.ERROR); + return; + } + } + } + catch (Exception e) + { + setMessage(e.getMessage()); + setMessageType(IMessageProvider.ERROR); + } + } + if (isValid()) + { + setMessage(null); + setMessageType(IMessageProvider.NONE); + } + } + + private void setMessage(String message, int type) + { + setMessage(message); + setMessageType(type); + } + + public void setValid(boolean valid) + { + this.valid = valid; + } + + public boolean isValid() + { + return valid; + } + + public void setMessage(String message) + { + this.message = message; + } + + public String getMessage() + { + return message; + } + + public void setMessageType(int messageType) + { + this.messageType = messageType; + } + + public int getMessageType() + { + return messageType; + } + + public void setResourceValidationType(int resourceValidationType) + { + this.resourceValidationType = resourceValidationType; + } + + public int getResourceValidationType() + { + return resourceValidationType; + } + + public void setValidationListener(ValidationListener validationListener) + { + this.validationListener = validationListener; + } + + public ValidationListener getValidationListener() + { + return validationListener; + } + } + + /** + * @author Martin Fluegge + */ + public static interface ValidationListener + { + public void validationFinished(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/composites/CDOResourceNodeSelectionWidget.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/composites/CDOResourceNodeSelectionWidget.java index 59201394cc..2c929918fb 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/composites/CDOResourceNodeSelectionWidget.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/composites/CDOResourceNodeSelectionWidget.java @@ -1,147 +1,147 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.composites; - -import org.eclipse.emf.cdo.dawn.ui.views.DawnWizardPageItemProvider; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.session.CDOSession; - -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.container.IManagedContainer; -import org.eclipse.net4j.util.container.IPluginContainer; -import org.eclipse.net4j.util.ui.views.ContainerItemProvider; -import org.eclipse.net4j.util.ui.views.IElementFilter; - -import org.eclipse.jface.viewers.DecoratingLabelProvider; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.PlatformUI; - -/** - * @author Martin Fluegge - * @since 1.0 - */ -public class CDOResourceNodeSelectionWidget extends Composite -{ - private ContainerItemProvider> itemProvider; - - private ShowResourcesViewFilter viewFilter; - - private TreeViewer viewer; - - public CDOResourceNodeSelectionWidget(Composite parent, int style) - { - super(parent, style); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginWidth = 0; - setLayout(layout); - init(); - } - - public void setShowResources(boolean showResources) - { - viewFilter.setShowResources(showResources); - } - - protected void init() - { - viewer = new TreeViewer(this, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - itemProvider = createContainerItemProvider(); - viewer.setContentProvider(createContentProvider()); - viewer.setLabelProvider(createLabelProvider()); - viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); - viewer.setInput(getManagedContainer()); - - viewFilter = new ShowResourcesViewFilter(); - viewer.addFilter(viewFilter); - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) - { - viewer.addSelectionChangedListener(listener); - } - - public void removeSelectionChangedListener(ISelectionChangedListener listener) - { - viewer.removeSelectionChangedListener(listener); - } - - protected IManagedContainer getManagedContainer() - { - return IPluginContainer.INSTANCE; - } - - protected IContentProvider createContentProvider() - { - return itemProvider; - } - - protected IBaseLabelProvider createLabelProvider() - { - ILabelDecorator labelDecorator = createLabelDecorator(); - return new DecoratingLabelProvider(itemProvider, labelDecorator); - } - - protected ILabelDecorator createLabelDecorator() - { - return PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(); - } - - protected ContainerItemProvider> createContainerItemProvider() - { - return new DawnWizardPageItemProvider>(new IElementFilter() - { - public boolean filter(Object element) - { - return element instanceof CDOSession; - } - }); - } - - /** - * @author Martin Fluegge - */ - protected class ShowResourcesViewFilter extends ViewerFilter - { - private boolean showResources; - - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) - { - if (element instanceof CDOResource) - { - return isShowResources(); - } - - return true; - } - - public void setShowResources(boolean showResources) - { - this.showResources = showResources; - } - - public boolean isShowResources() - { - return showResources; - } - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.composites; + +import org.eclipse.emf.cdo.dawn.ui.views.DawnWizardPageItemProvider; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.net4j.util.container.IContainer; +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.container.IPluginContainer; +import org.eclipse.net4j.util.ui.views.ContainerItemProvider; +import org.eclipse.net4j.util.ui.views.IElementFilter; + +import org.eclipse.jface.viewers.DecoratingLabelProvider; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ILabelDecorator; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.PlatformUI; + +/** + * @author Martin Fluegge + * @since 1.0 + */ +public class CDOResourceNodeSelectionWidget extends Composite +{ + private ContainerItemProvider> itemProvider; + + private ShowResourcesViewFilter viewFilter; + + private TreeViewer viewer; + + public CDOResourceNodeSelectionWidget(Composite parent, int style) + { + super(parent, style); + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + layout.marginWidth = 0; + setLayout(layout); + init(); + } + + public void setShowResources(boolean showResources) + { + viewFilter.setShowResources(showResources); + } + + protected void init() + { + viewer = new TreeViewer(this, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); + itemProvider = createContainerItemProvider(); + viewer.setContentProvider(createContentProvider()); + viewer.setLabelProvider(createLabelProvider()); + viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); + viewer.setInput(getManagedContainer()); + + viewFilter = new ShowResourcesViewFilter(); + viewer.addFilter(viewFilter); + } + + public void addSelectionChangedListener(ISelectionChangedListener listener) + { + viewer.addSelectionChangedListener(listener); + } + + public void removeSelectionChangedListener(ISelectionChangedListener listener) + { + viewer.removeSelectionChangedListener(listener); + } + + protected IManagedContainer getManagedContainer() + { + return IPluginContainer.INSTANCE; + } + + protected IContentProvider createContentProvider() + { + return itemProvider; + } + + protected IBaseLabelProvider createLabelProvider() + { + ILabelDecorator labelDecorator = createLabelDecorator(); + return new DecoratingLabelProvider(itemProvider, labelDecorator); + } + + protected ILabelDecorator createLabelDecorator() + { + return PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(); + } + + protected ContainerItemProvider> createContainerItemProvider() + { + return new DawnWizardPageItemProvider>(new IElementFilter() + { + public boolean filter(Object element) + { + return element instanceof CDOSession; + } + }); + } + + /** + * @author Martin Fluegge + */ + protected class ShowResourcesViewFilter extends ViewerFilter + { + private boolean showResources; + + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) + { + if (element instanceof CDOResource) + { + return isShowResources(); + } + + return true; + } + + public void setShowResources(boolean showResources) + { + this.showResources = showResources; + } + + public boolean isShowResources() + { + return showResources; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/LockObjectsHandler.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/LockObjectsHandler.java index a9b80eb746..7e325a3b1a 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/LockObjectsHandler.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/LockObjectsHandler.java @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.handlers; - -import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; -import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - -/** - * @author Martin Fluegge - * @since 2.0 - */ -public class LockObjectsHandler extends SelectionHandler -{ - public Object execute(ExecutionEvent event) throws ExecutionException - { - ((IDawnEditor)DawnEditorHelper.getActiveEditor()).getDawnEditorSupport().lockObjects(getSelectedObjects(event)); - - return null; - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.handlers; + +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; +import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public class LockObjectsHandler extends SelectionHandler +{ + public Object execute(ExecutionEvent event) throws ExecutionException + { + ((IDawnEditor)DawnEditorHelper.getActiveEditor()).getDawnEditorSupport().lockObjects(getSelectedObjects(event)); + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SelectionHandler.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SelectionHandler.java index 112f15a92b..791a05a169 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SelectionHandler.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SelectionHandler.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.handlers.HandlerUtil; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * @author Martin Fluegge - * @since 2.0 - */ -public abstract class SelectionHandler extends AbstractHandler -{ - protected List getSelectedObjects(ExecutionEvent event) - { - List objects = new ArrayList(); - ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection(); - if (selection != null & selection instanceof IStructuredSelection) - { - IStructuredSelection structuredSelection = (IStructuredSelection)selection; - for (@SuppressWarnings("unchecked") - Iterator iterator = structuredSelection.iterator(); iterator.hasNext();) - { - Object element = iterator.next(); - objects.add(element); - } - } - return objects; - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.handlers.HandlerUtil; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public abstract class SelectionHandler extends AbstractHandler +{ + protected List getSelectedObjects(ExecutionEvent event) + { + List objects = new ArrayList(); + ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection(); + if (selection != null & selection instanceof IStructuredSelection) + { + IStructuredSelection structuredSelection = (IStructuredSelection)selection; + for (@SuppressWarnings("unchecked") + Iterator iterator = structuredSelection.iterator(); iterator.hasNext();) + { + Object element = iterator.next(); + objects.add(element); + } + } + return objects; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java index 88f82791c2..1b7ddce4cd 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.handlers; - -import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; -import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; -import org.eclipse.emf.cdo.dawn.internal.ui.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.ui.IEditorPart; - -/** - * @author Martin Fluegge - */ -public class SolveConflictHandler extends AbstractHandler -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, SolveConflictHandler.class); - - public Object execute(ExecutionEvent event) throws ExecutionException - { - IEditorPart activeEditor = DawnEditorHelper.getActiveEditor(); - - if (TRACER.isEnabled()) - { - TRACER.format("Start solving conflicts for {0}", activeEditor); //$NON-NLS-1$ - } - - if (activeEditor instanceof IDawnEditor) - { - MessageDialog dialog = new MessageDialog(DawnEditorHelper.getActiveShell(), "Conflict", null, - "There are conflicts in your diagram. Would you like to rollback your current transaction?", - MessageDialog.QUESTION, new String[] { "yes", "no", "Cancel" }, 1); - - switch (dialog.open()) - { - case 0: // yes - ((IDawnEditor)activeEditor).getDawnEditorSupport().rollback(); - break; - case 1: // no - break; - default: // cancel - break; - } - } - return null; - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.handlers; + +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; +import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; +import org.eclipse.emf.cdo.dawn.internal.ui.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IEditorPart; + +/** + * @author Martin Fluegge + */ +public class SolveConflictHandler extends AbstractHandler +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, SolveConflictHandler.class); + + public Object execute(ExecutionEvent event) throws ExecutionException + { + IEditorPart activeEditor = DawnEditorHelper.getActiveEditor(); + + if (TRACER.isEnabled()) + { + TRACER.format("Start solving conflicts for {0}", activeEditor); //$NON-NLS-1$ + } + + if (activeEditor instanceof IDawnEditor) + { + MessageDialog dialog = new MessageDialog(DawnEditorHelper.getActiveShell(), "Conflict", null, + "There are conflicts in your diagram. Would you like to rollback your current transaction?", + MessageDialog.QUESTION, new String[] { "yes", "no", "Cancel" }, 1); + + switch (dialog.open()) + { + case 0: // yes + ((IDawnEditor)activeEditor).getDawnEditorSupport().rollback(); + break; + case 1: // no + break; + default: // cancel + break; + } + } + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java index 4c0898a82e..fe4d7ad8ec 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.handlers; - -import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; -import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - -/** - * @author Martin Fluegge - * @since 2.0 - */ -public class UnLockObjectsHandler extends SelectionHandler -{ - public Object execute(ExecutionEvent event) throws ExecutionException - { - ((IDawnEditor)DawnEditorHelper.getActiveEditor()).getDawnEditorSupport().unlockObjects(getSelectedObjects(event)); - - return null; - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.handlers; + +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; +import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; + +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public class UnLockObjectsHandler extends SelectionHandler +{ + public Object execute(ExecutionEvent event) throws ExecutionException + { + ((IDawnEditor)DawnEditorHelper.getActiveEditor()).getDawnEditorSupport().unlockObjects(getSelectedObjects(event)); + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/helper/EditorDescriptionHelper.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/helper/EditorDescriptionHelper.java index 5e583a086e..30255968b3 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/helper/EditorDescriptionHelper.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/helper/EditorDescriptionHelper.java @@ -1,96 +1,96 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.helper; - -import org.eclipse.emf.cdo.dawn.spi.IDawnUIElement; - -import org.eclipse.emf.ecore.resource.Resource; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.registry.EditorDescriptor; - -/** - * @author Martin Fluegge - */ -@SuppressWarnings("restriction") -public class EditorDescriptionHelper -{ - public static String getEditorIdForDawnEditor(String resourceName) - { - IEditorDescriptor editorDescriptor = getEditorDescriptorForDawnEditor(resourceName); - if (editorDescriptor != null) - { - return editorDescriptor.getId(); - } - return null; - } - - public static IEditorDescriptor getEditorDescriptorForDawnEditor(String resourceName) - { - IEditorDescriptor[] editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(resourceName); - - for (IEditorDescriptor editorDescriptor : editors) - { - EditorDescriptor des = (EditorDescriptor)editorDescriptor; - - try - { - IEditorPart editor = des.createEditor(); - if (editor instanceof IDawnUIElement) - { - return editorDescriptor; - } - } - catch (CoreException ex) - { - throw new RuntimeException(ex); - } - } - return null; - } - - public static IEditorDescriptor getEditorDescriptorFromFirstEditor(String resourceName) - { - IEditorDescriptor[] editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(resourceName); - if (editors.length > 0) - { - return editors[0]; - } - - return null; - } - - public static IEditorDescriptor getEditorDescriptorForDawnEditor(Resource resource) - { - return getEditorDescriptorForDawnEditor(resource.getURI().lastSegment()); - } - - public static Image getImageForEditor(String resourceName) - { - IEditorDescriptor editorDescriptor = getEditorDescriptorForDawnEditor(resourceName); - - if (editorDescriptor == null) - { - editorDescriptor = getEditorDescriptorFromFirstEditor(resourceName); - } - - if (editorDescriptor != null) - { - return editorDescriptor.getImageDescriptor().createImage(); - } - - return null; - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.helper; + +import org.eclipse.emf.cdo.dawn.spi.IDawnUIElement; + +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.IEditorDescriptor; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.internal.registry.EditorDescriptor; + +/** + * @author Martin Fluegge + */ +@SuppressWarnings("restriction") +public class EditorDescriptionHelper +{ + public static String getEditorIdForDawnEditor(String resourceName) + { + IEditorDescriptor editorDescriptor = getEditorDescriptorForDawnEditor(resourceName); + if (editorDescriptor != null) + { + return editorDescriptor.getId(); + } + return null; + } + + public static IEditorDescriptor getEditorDescriptorForDawnEditor(String resourceName) + { + IEditorDescriptor[] editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(resourceName); + + for (IEditorDescriptor editorDescriptor : editors) + { + EditorDescriptor des = (EditorDescriptor)editorDescriptor; + + try + { + IEditorPart editor = des.createEditor(); + if (editor instanceof IDawnUIElement) + { + return editorDescriptor; + } + } + catch (CoreException ex) + { + throw new RuntimeException(ex); + } + } + return null; + } + + public static IEditorDescriptor getEditorDescriptorFromFirstEditor(String resourceName) + { + IEditorDescriptor[] editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(resourceName); + if (editors.length > 0) + { + return editors[0]; + } + + return null; + } + + public static IEditorDescriptor getEditorDescriptorForDawnEditor(Resource resource) + { + return getEditorDescriptorForDawnEditor(resource.getURI().lastSegment()); + } + + public static Image getImageForEditor(String resourceName) + { + IEditorDescriptor editorDescriptor = getEditorDescriptorForDawnEditor(resourceName); + + if (editorDescriptor == null) + { + editorDescriptor = getEditorDescriptorFromFirstEditor(resourceName); + } + + if (editorDescriptor != null) + { + return editorDescriptor.getImageDescriptor().createImage(); + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/icons/DawnIconRegistry.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/icons/DawnIconRegistry.java index 8b79eccae4..e48079cb98 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/icons/DawnIconRegistry.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/icons/DawnIconRegistry.java @@ -1,103 +1,103 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Eike Stepper - initial API and implementation - * Victor Roldan Betancort - maintenance - */ -package org.eclipse.emf.cdo.dawn.ui.icons; - -import org.eclipse.emf.cdo.dawn.internal.ui.bundle.OM; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -/** - * Based on the implementation from org.eclipse.emf.cdo.ui.shared.SharedIcons. TODO clarify with Eike whether we could - * provide a better extensibility. - * - * @author Martin Fluegge - * @since 2.0 - */ -public class DawnIconRegistry -{ - private static final String GIF = ".gif"; //$NON-NLS-1$ - - private static final String PNG = ".png"; //$NON-NLS-1$ - - private static final ImageRegistry REGISTRY = new ImageRegistry(getDisplay()); - - private static final String ICONS_FOLDER = "icons/"; //$NON-NLS-1$ - - public static final String LOCKED = ICONS_FOLDER + "dawn_locked_16x16" + GIF; //$NON-NLS-1$ - - public static final String DAWN_LIGHT = ICONS_FOLDER + "dawn_16x16" + PNG; //$NON-NLS-1$ - - public static final String DAWN_DARK = ICONS_FOLDER + "dawn_16x16" + GIF; //$NON-NLS-1$ - - public static Image getImage(String key) - { - Image image = REGISTRY.get(key); - if (image == null) - { - createDescriptor(key); - image = REGISTRY.get(key); - } - - // For some reason, sometimes images get disposed. - // In that case, create and put in registry again. - if (image.isDisposed()) - { - REGISTRY.remove(key); - createDescriptor(key); - image = REGISTRY.get(key); - } - - return image; - } - - public static ImageDescriptor getDescriptor(String key) - { - ImageDescriptor descriptor = REGISTRY.getDescriptor(key); - if (descriptor == null) - { - descriptor = createDescriptor(key); - } - - return descriptor; - } - - private static ImageDescriptor createDescriptor(String key) - { - ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(OM.BUNDLE_ID, key); - if (descriptor != null) - { - REGISTRY.put(key, descriptor); - } - - return descriptor; - } - - private static Display getDisplay() - { - Display display = Display.getCurrent(); - if (display == null) - { - display = Display.getDefault(); - } - - if (display == null) - { - throw new IllegalStateException("display == null"); //$NON-NLS-1$ - } - - return display; - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.dawn.ui.icons; + +import org.eclipse.emf.cdo.dawn.internal.ui.bundle.OM; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +/** + * Based on the implementation from org.eclipse.emf.cdo.ui.shared.SharedIcons. TODO clarify with Eike whether we could + * provide a better extensibility. + * + * @author Martin Fluegge + * @since 2.0 + */ +public class DawnIconRegistry +{ + private static final String GIF = ".gif"; //$NON-NLS-1$ + + private static final String PNG = ".png"; //$NON-NLS-1$ + + private static final ImageRegistry REGISTRY = new ImageRegistry(getDisplay()); + + private static final String ICONS_FOLDER = "icons/"; //$NON-NLS-1$ + + public static final String LOCKED = ICONS_FOLDER + "dawn_locked_16x16" + GIF; //$NON-NLS-1$ + + public static final String DAWN_LIGHT = ICONS_FOLDER + "dawn_16x16" + PNG; //$NON-NLS-1$ + + public static final String DAWN_DARK = ICONS_FOLDER + "dawn_16x16" + GIF; //$NON-NLS-1$ + + public static Image getImage(String key) + { + Image image = REGISTRY.get(key); + if (image == null) + { + createDescriptor(key); + image = REGISTRY.get(key); + } + + // For some reason, sometimes images get disposed. + // In that case, create and put in registry again. + if (image.isDisposed()) + { + REGISTRY.remove(key); + createDescriptor(key); + image = REGISTRY.get(key); + } + + return image; + } + + public static ImageDescriptor getDescriptor(String key) + { + ImageDescriptor descriptor = REGISTRY.getDescriptor(key); + if (descriptor == null) + { + descriptor = createDescriptor(key); + } + + return descriptor; + } + + private static ImageDescriptor createDescriptor(String key) + { + ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(OM.BUNDLE_ID, key); + if (descriptor != null) + { + REGISTRY.put(key, descriptor); + } + + return descriptor; + } + + private static Display getDisplay() + { + Display display = Display.getCurrent(); + if (display == null) + { + display = Display.getDefault(); + } + + if (display == null) + { + throw new IllegalStateException("display == null"); //$NON-NLS-1$ + } + + return display; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/messages/Messages.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/messages/Messages.java index a89d8c1ac6..4fd4c457bc 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/messages/Messages.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/messages/Messages.java @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.messages; - -import org.eclipse.osgi.util.NLS; - -/** - * @author Martin Fluegge - * @since 2.0 - */ -public class Messages extends NLS -{ - private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.dawn.ui.messages.messages"; //$NON-NLS-1$ - - public static String CDOResourceNodeChooserComposite_1; - - public static String DawnCreateNewResourceWizardPage_0; - - public static String DawnCreateNewResourceWizardPage_10; - - public static String DawnCreateNewResourceWizardPage_11; - - public static String DawnCreateNewResourceWizardPage_12; - - public static String DawnCreateNewResourceWizardPage_2; - - public static String DawnCreateNewResourceWizardPage_3; - - public static String DawnCreateNewResourceWizardPage_6; - - public static String DawnCreateNewResourceWizardPage_8; - static - { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() - { - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.messages; + +import org.eclipse.osgi.util.NLS; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public class Messages extends NLS +{ + private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.dawn.ui.messages.messages"; //$NON-NLS-1$ + + public static String CDOResourceNodeChooserComposite_1; + + public static String DawnCreateNewResourceWizardPage_0; + + public static String DawnCreateNewResourceWizardPage_10; + + public static String DawnCreateNewResourceWizardPage_11; + + public static String DawnCreateNewResourceWizardPage_12; + + public static String DawnCreateNewResourceWizardPage_2; + + public static String DawnCreateNewResourceWizardPage_3; + + public static String DawnCreateNewResourceWizardPage_6; + + public static String DawnCreateNewResourceWizardPage_8; + static + { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() + { + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/messages/messages.properties b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/messages/messages.properties index 3bbb83376b..0f1620ff7c 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/messages/messages.properties +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/messages/messages.properties @@ -1,18 +1,18 @@ -# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: -# Martin Fluegge - initial API and implementation - -CDOResourceNodeChooserComposite_1=Resource name must have the suffix -DawnCreateNewResourceWizardPage_0=First Page -DawnCreateNewResourceWizardPage_10=Please insert a name for the resource -DawnCreateNewResourceWizardPage_11=A resource with the same name already exists\! -DawnCreateNewResourceWizardPage_12=A resource with the same name already exists\! -DawnCreateNewResourceWizardPage_2=Create a Dawn Resource -DawnCreateNewResourceWizardPage_3=Creates Dawn Resource -DawnCreateNewResourceWizardPage_6=Resource name: -DawnCreateNewResourceWizardPage_8=Enter or select the parent folder: +# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: +# Martin Fluegge - initial API and implementation + +CDOResourceNodeChooserComposite_1=Resource name must have the suffix +DawnCreateNewResourceWizardPage_0=First Page +DawnCreateNewResourceWizardPage_10=Please insert a name for the resource +DawnCreateNewResourceWizardPage_11=A resource with the same name already exists\! +DawnCreateNewResourceWizardPage_12=A resource with the same name already exists\! +DawnCreateNewResourceWizardPage_2=Create a Dawn Resource +DawnCreateNewResourceWizardPage_3=Creates Dawn Resource +DawnCreateNewResourceWizardPage_6=Resource name: +DawnCreateNewResourceWizardPage_8=Enter or select the parent folder: diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/stylizer/DawnDefaultElementStylizer.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/stylizer/DawnDefaultElementStylizer.java index 94124ed169..78d6c28490 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/stylizer/DawnDefaultElementStylizer.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/stylizer/DawnDefaultElementStylizer.java @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.stylizer; - -import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer; -import org.eclipse.emf.cdo.dawn.spi.DawnState; -import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants; -import org.eclipse.emf.cdo.dawn.ui.icons.DawnIconRegistry; - -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; - -/** - * @author Martin Fluegge - * @since 2.0 - */ -public class DawnDefaultElementStylizer implements DawnElementStylizer -{ - public void setDefault(Object element) - { - } - - public void setConflicted(Object element, int type) - { - } - - public void setLocked(Object element, int type) - { - } - - public Image getImage(Object element, DawnState state) - { - switch (state) - { - case LOCKED_LOCALLY: - { - return DawnIconRegistry.getImage(DawnIconRegistry.LOCKED); - } - case LOCKED_REMOTELY: - { - return DawnIconRegistry.getImage(DawnIconRegistry.LOCKED); - } - } - return null; - } - - public Color getForegroundColor(Object element, DawnState state) - { - switch (state) - { - case CONFLICT: - { - return DawnColorConstants.COLOR_DELETE_CONFLICT; - } - } - - return null; - } - - public Color getBackgroundColor(Object element, DawnState state) - { - switch (state) - { - case LOCKED_LOCALLY: - { - return DawnColorConstants.COLOR_LOCKED_LOCALLY; - } - case LOCKED_REMOTELY: - { - return DawnColorConstants.COLOR_LOCKED_REMOTELY; - } - } - - return null; - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.stylizer; + +import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer; +import org.eclipse.emf.cdo.dawn.spi.DawnState; +import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants; +import org.eclipse.emf.cdo.dawn.ui.icons.DawnIconRegistry; + +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public class DawnDefaultElementStylizer implements DawnElementStylizer +{ + public void setDefault(Object element) + { + } + + public void setConflicted(Object element, int type) + { + } + + public void setLocked(Object element, int type) + { + } + + public Image getImage(Object element, DawnState state) + { + switch (state) + { + case LOCKED_LOCALLY: + { + return DawnIconRegistry.getImage(DawnIconRegistry.LOCKED); + } + case LOCKED_REMOTELY: + { + return DawnIconRegistry.getImage(DawnIconRegistry.LOCKED); + } + } + return null; + } + + public Color getForegroundColor(Object element, DawnState state) + { + switch (state) + { + case CONFLICT: + { + return DawnColorConstants.COLOR_DELETE_CONFLICT; + } + } + + return null; + } + + public Color getBackgroundColor(Object element, DawnState state) + { + switch (state) + { + case LOCKED_LOCALLY: + { + return DawnColorConstants.COLOR_LOCKED_LOCALLY; + } + case LOCKED_REMOTELY: + { + return DawnColorConstants.COLOR_LOCKED_REMOTELY; + } + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/stylizer/DawnElementStylizerRegistry.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/stylizer/DawnElementStylizerRegistry.java index 182a84a73c..bb0a1bc10a 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/stylizer/DawnElementStylizerRegistry.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/stylizer/DawnElementStylizerRegistry.java @@ -1,162 +1,162 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.stylizer; - -import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer; -import org.eclipse.emf.cdo.dawn.appearance.IDawnElementStylizerFactory; -import org.eclipse.emf.cdo.dawn.internal.ui.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.InvalidRegistryObjectException; -import org.eclipse.core.runtime.Platform; - -import java.util.HashMap; -import java.util.Map; - -/** - * This registry provides the DawnElementStylizer implementation for a given object. - * - * @see org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer - * @author Martin Fluegge - * @since 2.0 - */ -public class DawnElementStylizerRegistry -{ - private static final String ATTRIBUTE_PRIORITY = "priority"; - - private static final String ATTRIIBUTE_FACTORY = "factory"; - - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DawnElementStylizerRegistry.class); - - private static final String DAWN_STYLIZER_FACTORY_EXTENSION_POINT_ID = "org.eclipse.emf.cdo.dawn.elementstylizerfactory"; - - public static DawnElementStylizerRegistry instance = new DawnElementStylizerRegistry(); - - private Map registeredStylizers = new HashMap(); - - private Map stylizerFactories = new HashMap(); - - private DawnDefaultElementStylizer dawnDefaultElementStylizer; - - /** - * @since 2.0 - */ - public DawnElementStylizer getStylizer(Object object) - { - DawnElementStylizer stylizer = registeredStylizers.get(object.getClass().getCanonicalName()); - - if (stylizer == null) - { - stylizer = getStylizerFromExtensionPoint(object); - registeredStylizers.put(object.getClass().getCanonicalName(), stylizer); - } - - if (stylizer == null) - { - stylizer = getDefaultStylizer(object); - } - - return stylizer; - } - - private DawnElementStylizer getDefaultStylizer(Object object) - { - dawnDefaultElementStylizer = new DawnDefaultElementStylizer(); - return dawnDefaultElementStylizer; - } - - private DawnElementStylizer getStylizerFromExtensionPoint(Object object) - { - Map factories = getFactories(); - DawnElementStylizer elementStylizer = null; - int lastPriority = -1; - - for (FactoryContainer factoryContainer : factories.values()) - { - DawnElementStylizer currentElementStylizer = factoryContainer.getFactory().getElementStylizer(object); - if (currentElementStylizer != null) - { - int priority = factoryContainer.getPriority(); - if (priority > lastPriority) - { - elementStylizer = currentElementStylizer; - lastPriority = priority; - } - } - } - - return elementStylizer; - } - - private Map getFactories() - { - try - { - IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( - DAWN_STYLIZER_FACTORY_EXTENSION_POINT_ID); - for (IConfigurationElement e : config) - { - String factoryClassName = e.getAttribute(ATTRIIBUTE_FACTORY); - if (!stylizerFactories.containsKey(factoryClassName)) - { - IDawnElementStylizerFactory stylizer = (IDawnElementStylizerFactory)e - .createExecutableExtension(ATTRIIBUTE_FACTORY); - - int priority = Integer.parseInt(e.getAttribute(ATTRIBUTE_PRIORITY).substring(0, 1)); - - FactoryContainer container = new FactoryContainer(priority, stylizer); - - stylizerFactories.put(factoryClassName, container); - if (TRACER.isEnabled()) - { - TRACER.format("Registered IDawnElementStylizerFactory {0} ", stylizer); //$NON-NLS-1$ - } - } - } - } - catch (InvalidRegistryObjectException e) - { - e.printStackTrace(); - } - catch (CoreException e) - { - e.printStackTrace(); - } - - return stylizerFactories; - } - - private class FactoryContainer - { - private int priority; - - private IDawnElementStylizerFactory factory; - - public FactoryContainer(int priority, IDawnElementStylizerFactory factory) - { - this.priority = priority; - this.factory = factory; - } - - public IDawnElementStylizerFactory getFactory() - { - return factory; - } - - public int getPriority() - { - return priority; - } - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.stylizer; + +import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer; +import org.eclipse.emf.cdo.dawn.appearance.IDawnElementStylizerFactory; +import org.eclipse.emf.cdo.dawn.internal.ui.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.Platform; + +import java.util.HashMap; +import java.util.Map; + +/** + * This registry provides the DawnElementStylizer implementation for a given object. + * + * @see org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer + * @author Martin Fluegge + * @since 2.0 + */ +public class DawnElementStylizerRegistry +{ + private static final String ATTRIBUTE_PRIORITY = "priority"; + + private static final String ATTRIIBUTE_FACTORY = "factory"; + + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DawnElementStylizerRegistry.class); + + private static final String DAWN_STYLIZER_FACTORY_EXTENSION_POINT_ID = "org.eclipse.emf.cdo.dawn.elementstylizerfactory"; + + public static DawnElementStylizerRegistry instance = new DawnElementStylizerRegistry(); + + private Map registeredStylizers = new HashMap(); + + private Map stylizerFactories = new HashMap(); + + private DawnDefaultElementStylizer dawnDefaultElementStylizer; + + /** + * @since 2.0 + */ + public DawnElementStylizer getStylizer(Object object) + { + DawnElementStylizer stylizer = registeredStylizers.get(object.getClass().getCanonicalName()); + + if (stylizer == null) + { + stylizer = getStylizerFromExtensionPoint(object); + registeredStylizers.put(object.getClass().getCanonicalName(), stylizer); + } + + if (stylizer == null) + { + stylizer = getDefaultStylizer(object); + } + + return stylizer; + } + + private DawnElementStylizer getDefaultStylizer(Object object) + { + dawnDefaultElementStylizer = new DawnDefaultElementStylizer(); + return dawnDefaultElementStylizer; + } + + private DawnElementStylizer getStylizerFromExtensionPoint(Object object) + { + Map factories = getFactories(); + DawnElementStylizer elementStylizer = null; + int lastPriority = -1; + + for (FactoryContainer factoryContainer : factories.values()) + { + DawnElementStylizer currentElementStylizer = factoryContainer.getFactory().getElementStylizer(object); + if (currentElementStylizer != null) + { + int priority = factoryContainer.getPriority(); + if (priority > lastPriority) + { + elementStylizer = currentElementStylizer; + lastPriority = priority; + } + } + } + + return elementStylizer; + } + + private Map getFactories() + { + try + { + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( + DAWN_STYLIZER_FACTORY_EXTENSION_POINT_ID); + for (IConfigurationElement e : config) + { + String factoryClassName = e.getAttribute(ATTRIIBUTE_FACTORY); + if (!stylizerFactories.containsKey(factoryClassName)) + { + IDawnElementStylizerFactory stylizer = (IDawnElementStylizerFactory)e + .createExecutableExtension(ATTRIIBUTE_FACTORY); + + int priority = Integer.parseInt(e.getAttribute(ATTRIBUTE_PRIORITY).substring(0, 1)); + + FactoryContainer container = new FactoryContainer(priority, stylizer); + + stylizerFactories.put(factoryClassName, container); + if (TRACER.isEnabled()) + { + TRACER.format("Registered IDawnElementStylizerFactory {0} ", stylizer); //$NON-NLS-1$ + } + } + } + } + catch (InvalidRegistryObjectException e) + { + e.printStackTrace(); + } + catch (CoreException e) + { + e.printStackTrace(); + } + + return stylizerFactories; + } + + private class FactoryContainer + { + private int priority; + + private IDawnElementStylizerFactory factory; + + public FactoryContainer(int priority, IDawnElementStylizerFactory factory) + { + this.priority = priority; + this.factory = factory; + } + + public IDawnElementStylizerFactory getFactory() + { + return factory; + } + + public int getPriority() + { + return priority; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/views/DawnItemProvider.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/views/DawnItemProvider.java index de9dbb8061..846425bf2b 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/views/DawnItemProvider.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/views/DawnItemProvider.java @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.views; - -import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.eresource.CDOResourceFolder; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.ui.CDOItemProvider; - -import org.eclipse.net4j.util.ui.views.IElementFilter; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IWorkbenchPage; - -/** - * @author Martin Fluegge - */ -public class DawnItemProvider extends CDOItemProvider -{ - private final DawnExplorer dawnExplorer; - - public DawnItemProvider(IWorkbenchPage page, DawnExplorer dawnExplorer, IElementFilter rootElementFilter) - { - super(page, rootElementFilter); - this.dawnExplorer = dawnExplorer; - } - - @Override - public Object[] getChildren(Object element) - { - // if (element instanceof CDOView) - // { - // return ((CDOView)element).getRootResource().getContents().toArray(); - // } - - if (element instanceof CDOResourceFolder) - { - return ((CDOResourceFolder)element).getNodes().toArray(); - } - - if (element instanceof CDOSession) - { - CDOSession session = (CDOSession)element; - Object[] child = new Object[1]; - child[0] = session.getView(dawnExplorer.getView().getViewID()); - return child; - } - - return super.getChildren(element); - } - - @Override - public Image getImage(Object obj) - { - if (obj instanceof CDOResource) - { - CDOResource resource = (CDOResource)obj; - Image img = EditorDescriptionHelper.getImageForEditor(resource.getName()); - if (img != null) - { - return img; - } - } - - return super.getImage(obj); - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.views; + +import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.ui.CDOItemProvider; + +import org.eclipse.net4j.util.ui.views.IElementFilter; + +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.IWorkbenchPage; + +/** + * @author Martin Fluegge + */ +public class DawnItemProvider extends CDOItemProvider +{ + private final DawnExplorer dawnExplorer; + + public DawnItemProvider(IWorkbenchPage page, DawnExplorer dawnExplorer, IElementFilter rootElementFilter) + { + super(page, rootElementFilter); + this.dawnExplorer = dawnExplorer; + } + + @Override + public Object[] getChildren(Object element) + { + // if (element instanceof CDOView) + // { + // return ((CDOView)element).getRootResource().getContents().toArray(); + // } + + if (element instanceof CDOResourceFolder) + { + return ((CDOResourceFolder)element).getNodes().toArray(); + } + + if (element instanceof CDOSession) + { + CDOSession session = (CDOSession)element; + Object[] child = new Object[1]; + child[0] = session.getView(dawnExplorer.getView().getViewID()); + return child; + } + + return super.getChildren(element); + } + + @Override + public Image getImage(Object obj) + { + if (obj instanceof CDOResource) + { + CDOResource resource = (CDOResource)obj; + Image img = EditorDescriptionHelper.getImageForEditor(resource.getName()); + if (img != null) + { + return img; + } + } + + return super.getImage(obj); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/views/DawnWizardPageItemProvider.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/views/DawnWizardPageItemProvider.java index b11bc27f83..bed0faf0f5 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/views/DawnWizardPageItemProvider.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/views/DawnWizardPageItemProvider.java @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.views; - -import org.eclipse.emf.cdo.eresource.CDOResourceFolder; -import org.eclipse.emf.cdo.eresource.CDOResourceNode; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.ui.CDOItemProvider; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.ui.views.IElementFilter; - -/** - * @author Martin Fluegge - * @param - */ -public class DawnWizardPageItemProvider> extends CDOItemProvider -{ - - public DawnWizardPageItemProvider(IElementFilter iElementFilter) - { - super(null, iElementFilter); - } - - @Override - public Object[] getChildren(Object element) - { - if (element instanceof CDOResourceFolder) - { - return ((CDOResourceFolder)element).getNodes().toArray(); - } - - if (element instanceof CDOSession) - { - CDOSession session = (CDOSession)element; - Object[] child = new Object[1]; - child[0] = session.getViews()[0];// .getView(dawnExplorer.getView().getViewID()); - return child; - } - - return super.getChildren(element); - } - - @Override - public boolean hasChildren(Object element) - { - if (element instanceof CDOView) - { - return ((CDOView)element).getRootResource().getContents().size() > 0; - } - - if (element instanceof CDOResourceFolder) - { - return ((CDOResourceFolder)element).getNodes().size() > 0; - } - - return super.hasChildren(element); - } - - @Override - public Object getParent(Object element) - { - if (element instanceof CDOResourceNode) - { - CDOResourceNode node = (CDOResourceNode)element; - CDOResourceNode parent = (CDOResourceNode)node.eContainer(); - if (parent.isRoot()) - { - return parent.cdoView(); - } - - return parent; - } - - return super.getParent(element); - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.views; + +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.ui.CDOItemProvider; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.util.container.IContainer; +import org.eclipse.net4j.util.ui.views.IElementFilter; + +/** + * @author Martin Fluegge + * @param + */ +public class DawnWizardPageItemProvider> extends CDOItemProvider +{ + + public DawnWizardPageItemProvider(IElementFilter iElementFilter) + { + super(null, iElementFilter); + } + + @Override + public Object[] getChildren(Object element) + { + if (element instanceof CDOResourceFolder) + { + return ((CDOResourceFolder)element).getNodes().toArray(); + } + + if (element instanceof CDOSession) + { + CDOSession session = (CDOSession)element; + Object[] child = new Object[1]; + child[0] = session.getViews()[0];// .getView(dawnExplorer.getView().getViewID()); + return child; + } + + return super.getChildren(element); + } + + @Override + public boolean hasChildren(Object element) + { + if (element instanceof CDOView) + { + return ((CDOView)element).getRootResource().getContents().size() > 0; + } + + if (element instanceof CDOResourceFolder) + { + return ((CDOResourceFolder)element).getNodes().size() > 0; + } + + return super.hasChildren(element); + } + + @Override + public Object getParent(Object element) + { + if (element instanceof CDOResourceNode) + { + CDOResourceNode node = (CDOResourceNode)element; + CDOResourceNode parent = (CDOResourceNode)node.eContainer(); + if (parent.isRoot()) + { + return parent.cdoView(); + } + + return parent; + } + + return super.getParent(element); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/DawnCreateNewDiagramResourceWizardPage.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/DawnCreateNewDiagramResourceWizardPage.java index 2171c2ba34..0ebb4a88f6 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/DawnCreateNewDiagramResourceWizardPage.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/DawnCreateNewDiagramResourceWizardPage.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.wizards; - -import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.URI; - -/** - * @author Martin Fluegge - */ -public class DawnCreateNewDiagramResourceWizardPage extends DawnCreateNewResourceWizardPage -{ - public DawnCreateNewDiagramResourceWizardPage(String fileExtension) - { - super(fileExtension); - } - - public DawnCreateNewDiagramResourceWizardPage(String fileExtension, boolean showResources, CDOView view) - { - super(fileExtension, showResources, view); - } - - @Override - public URI getURI() - { - // TODO check why the dawn resource must be connected this way - return URI.createURI("dawn://" + PreferenceConstants.getRepositoryName() + "/" + chooserComposite.getResourcePath() - + "/" + chooserComposite.getResourceName()); - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.wizards; + +import org.eclipse.emf.cdo.dawn.preferences.PreferenceConstants; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.util.URI; + +/** + * @author Martin Fluegge + */ +public class DawnCreateNewDiagramResourceWizardPage extends DawnCreateNewResourceWizardPage +{ + public DawnCreateNewDiagramResourceWizardPage(String fileExtension) + { + super(fileExtension); + } + + public DawnCreateNewDiagramResourceWizardPage(String fileExtension, boolean showResources, CDOView view) + { + super(fileExtension, showResources, view); + } + + @Override + public URI getURI() + { + // TODO check why the dawn resource must be connected this way + return URI.createURI("dawn://" + PreferenceConstants.getRepositoryName() + "/" + chooserComposite.getResourcePath() + + "/" + chooserComposite.getResourceName()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/DawnCreateNewResourceWizardPage.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/DawnCreateNewResourceWizardPage.java index ee58242659..f09bce82d9 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/DawnCreateNewResourceWizardPage.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/DawnCreateNewResourceWizardPage.java @@ -1,185 +1,185 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.ui.wizards; - -import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite; -import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ResourceChooserValidator; -import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ValidationListener; -import org.eclipse.emf.cdo.dawn.ui.messages.Messages; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; - -/** - * @author Martin Fluegge - */ -public class DawnCreateNewResourceWizardPage extends WizardPage -{ - private Composite container; - - private boolean showResources; - - private final String fileExtension; - - private int resourceValidationType = ResourceChooserValidator.VALIDATION_ERROR; - - /** - * left for backward compatibility with the generated editors. This field might soon be removed. Use - * org.eclipse.emf.cdo.dawn.ui.composites.ResourceChooserValidator.VALIDATION_WARN instead. - */ - @Deprecated - public static final int VALIDATION_WARN = ResourceChooserValidator.VALIDATION_WARN; - - private final CDOView view; - - //private String resourceNamePrefix = "default"; //$NON-NLS-1$ - - private boolean createAutomaticResourceName; - - /** - * @since 1.0 - */ - protected CDOResourceNodeChooserComposite chooserComposite; - - public DawnCreateNewResourceWizardPage(String fileExtension) - { - this(fileExtension, true, null); - } - - public DawnCreateNewResourceWizardPage(String fileExtension, boolean showResources, CDOView view) - { - super(Messages.DawnCreateNewResourceWizardPage_0); - this.view = view; - setTitle(Messages.DawnCreateNewResourceWizardPage_2); - setDescription(Messages.DawnCreateNewResourceWizardPage_3); - this.showResources = showResources; - this.fileExtension = fileExtension; - } - - public void createControl(Composite parent) - { - container = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - container.setLayout(layout); - layout.numColumns = 1; - chooserComposite = new CDOResourceNodeChooserComposite(container, SWT.NONE, fileExtension, view); - chooserComposite.showResources(showResources); - ResourceChooserValidator validator = chooserComposite.getValidator(); - validator.setResourceValidationType(resourceValidationType); - validator.setValidationListener(new ValidationListener() - { - public void validationFinished() - { - validatePage(); - } - }); - - if (createAutomaticResourceName) - { - chooserComposite.createAutomaticResourceName(); - } - - GridData gd = new GridData(GridData.FILL_BOTH); - chooserComposite.setLayoutData(gd); - - setControl(container); - validator.validate(); - } - - private void validatePage() - { - ResourceChooserValidator validator = chooserComposite.getValidator(); - boolean valid = validator.isValid(); - - if (!valid) - { - int type = validator.getMessageType(); - setMessage(validator.getMessage(), type); - } - else - { - setMessage(""); - } - setPageComplete(valid); - } - - public URI getURI() - { - return chooserComposite.getURI(); - } - - public void setShowResources(boolean showResources) - { - this.showResources = showResources; - } - - public boolean isShowResources() - { - return showResources; - } - - public void setResourceNamePrefix(String resourceNamePrefix) - { - // this.resourceNamePrefix = resourceNamePrefix; - chooserComposite.setResourceNamePrefix(resourceNamePrefix); - chooserComposite.setResourceName(resourceNamePrefix); - } - - public String getResourceNamePrefix() - { - return chooserComposite.getResourceNamePrefix(); - } - - public void setResourcePath(String text) - { - if (!text.endsWith("/") || !!text.endsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$ - { - text += "/"; //$NON-NLS-1$ - } - chooserComposite.setResourcePath(text); - } - - public String getResourcePath() - { - return chooserComposite.getResourcePath(); - } - - public void setCreateAutomaticResourceName(boolean createAutomaticResourceName) - { - this.createAutomaticResourceName = createAutomaticResourceName; - } - - public boolean isCreateAutomaticResourceName() - { - return createAutomaticResourceName; - } - - public void setResourceValidationType(int resourceValidationType) - { - this.resourceValidationType = resourceValidationType; - } - - public int getResourceValidationType() - { - return resourceValidationType; - } - - public String getDefaultName() - { - return chooserComposite.getDefaultName(); - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.ui.wizards; + +import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite; +import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ResourceChooserValidator; +import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ValidationListener; +import org.eclipse.emf.cdo.dawn.ui.messages.Messages; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; + +/** + * @author Martin Fluegge + */ +public class DawnCreateNewResourceWizardPage extends WizardPage +{ + private Composite container; + + private boolean showResources; + + private final String fileExtension; + + private int resourceValidationType = ResourceChooserValidator.VALIDATION_ERROR; + + /** + * left for backward compatibility with the generated editors. This field might soon be removed. Use + * org.eclipse.emf.cdo.dawn.ui.composites.ResourceChooserValidator.VALIDATION_WARN instead. + */ + @Deprecated + public static final int VALIDATION_WARN = ResourceChooserValidator.VALIDATION_WARN; + + private final CDOView view; + + //private String resourceNamePrefix = "default"; //$NON-NLS-1$ + + private boolean createAutomaticResourceName; + + /** + * @since 1.0 + */ + protected CDOResourceNodeChooserComposite chooserComposite; + + public DawnCreateNewResourceWizardPage(String fileExtension) + { + this(fileExtension, true, null); + } + + public DawnCreateNewResourceWizardPage(String fileExtension, boolean showResources, CDOView view) + { + super(Messages.DawnCreateNewResourceWizardPage_0); + this.view = view; + setTitle(Messages.DawnCreateNewResourceWizardPage_2); + setDescription(Messages.DawnCreateNewResourceWizardPage_3); + this.showResources = showResources; + this.fileExtension = fileExtension; + } + + public void createControl(Composite parent) + { + container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 1; + chooserComposite = new CDOResourceNodeChooserComposite(container, SWT.NONE, fileExtension, view); + chooserComposite.showResources(showResources); + ResourceChooserValidator validator = chooserComposite.getValidator(); + validator.setResourceValidationType(resourceValidationType); + validator.setValidationListener(new ValidationListener() + { + public void validationFinished() + { + validatePage(); + } + }); + + if (createAutomaticResourceName) + { + chooserComposite.createAutomaticResourceName(); + } + + GridData gd = new GridData(GridData.FILL_BOTH); + chooserComposite.setLayoutData(gd); + + setControl(container); + validator.validate(); + } + + private void validatePage() + { + ResourceChooserValidator validator = chooserComposite.getValidator(); + boolean valid = validator.isValid(); + + if (!valid) + { + int type = validator.getMessageType(); + setMessage(validator.getMessage(), type); + } + else + { + setMessage(""); + } + setPageComplete(valid); + } + + public URI getURI() + { + return chooserComposite.getURI(); + } + + public void setShowResources(boolean showResources) + { + this.showResources = showResources; + } + + public boolean isShowResources() + { + return showResources; + } + + public void setResourceNamePrefix(String resourceNamePrefix) + { + // this.resourceNamePrefix = resourceNamePrefix; + chooserComposite.setResourceNamePrefix(resourceNamePrefix); + chooserComposite.setResourceName(resourceNamePrefix); + } + + public String getResourceNamePrefix() + { + return chooserComposite.getResourceNamePrefix(); + } + + public void setResourcePath(String text) + { + if (!text.endsWith("/") || !!text.endsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$ + { + text += "/"; //$NON-NLS-1$ + } + chooserComposite.setResourcePath(text); + } + + public String getResourcePath() + { + return chooserComposite.getResourcePath(); + } + + public void setCreateAutomaticResourceName(boolean createAutomaticResourceName) + { + this.createAutomaticResourceName = createAutomaticResourceName; + } + + public boolean isCreateAutomaticResourceName() + { + return createAutomaticResourceName; + } + + public void setResourceValidationType(int resourceValidationType) + { + this.resourceValidationType = resourceValidationType; + } + + public int getResourceValidationType() + { + return resourceValidationType; + } + + public String getDefaultName() + { + return chooserComposite.getDefaultName(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/dialogs/CDOResourceNodeSelectionDialog.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/dialogs/CDOResourceNodeSelectionDialog.java index a32d247bef..f0aca3f064 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/dialogs/CDOResourceNodeSelectionDialog.java +++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/wizards/dialogs/CDOResourceNodeSelectionDialog.java @@ -1,94 +1,94 @@ -/* - * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: - * Eike Stepper - initial API and implementation - * Martin Fluegge - bug 247226: Transparently support legacy models - */ -package org.eclipse.emf.cdo.dawn.ui.wizards.dialogs; - -import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -/** - * @since 1.0 - * @author Martin Fluegge - */ -public class CDOResourceNodeSelectionDialog extends Dialog -{ - private final CDOView view; - - private CDOResourceNodeChooserComposite chooserComposite; - - private boolean showResources = false; - - private URI uri; - - public CDOResourceNodeSelectionDialog(Shell parentShell, CDOView view) - { - super(parentShell); - this.view = view; - } - - public CDOResourceNodeSelectionDialog(Shell parentShell, CDOView view, boolean showResources) - { - super(parentShell); - this.view = view; - this.showResources = showResources; - } - - @Override - protected Control createDialogArea(Composite parent) - { - Control parentControl = super.createDialogArea(parent); - chooserComposite = new CDOResourceNodeChooserComposite((Composite)parentControl, SWT.NONE, "ecore", view); - - chooserComposite.showResources(showResources); - chooserComposite.createAutomaticResourceName(); - GridData gd = new GridData(GridData.FILL_BOTH); - chooserComposite.setLayoutData(gd); - - return parentControl; - } - - @Override - protected Control createButtonBar(Composite parent) - { - Control buttonBar = super.createButtonBar(parent); - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER); - buttonBar.setLayoutData(gd); - getShell().pack(); - return buttonBar; - } - - @Override - protected void initializeBounds() - { - getShell().setSize(300, 400); - } - - public URI getResults() - { - return uri; - } - - @Override - public boolean close() - { - uri = chooserComposite.getURI(); - return super.close(); - } -} +/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + * Martin Fluegge - bug 247226: Transparently support legacy models + */ +package org.eclipse.emf.cdo.dawn.ui.wizards.dialogs; + +import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +/** + * @since 1.0 + * @author Martin Fluegge + */ +public class CDOResourceNodeSelectionDialog extends Dialog +{ + private final CDOView view; + + private CDOResourceNodeChooserComposite chooserComposite; + + private boolean showResources = false; + + private URI uri; + + public CDOResourceNodeSelectionDialog(Shell parentShell, CDOView view) + { + super(parentShell); + this.view = view; + } + + public CDOResourceNodeSelectionDialog(Shell parentShell, CDOView view, boolean showResources) + { + super(parentShell); + this.view = view; + this.showResources = showResources; + } + + @Override + protected Control createDialogArea(Composite parent) + { + Control parentControl = super.createDialogArea(parent); + chooserComposite = new CDOResourceNodeChooserComposite((Composite)parentControl, SWT.NONE, "ecore", view); + + chooserComposite.showResources(showResources); + chooserComposite.createAutomaticResourceName(); + GridData gd = new GridData(GridData.FILL_BOTH); + chooserComposite.setLayoutData(gd); + + return parentControl; + } + + @Override + protected Control createButtonBar(Composite parent) + { + Control buttonBar = super.createButtonBar(parent); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER); + buttonBar.setLayoutData(gd); + getShell().pack(); + return buttonBar; + } + + @Override + protected void initializeBounds() + { + getShell().setSize(300, 400); + } + + public URI getResults() + { + return uri; + } + + @Override + public boolean close() + { + uri = chooserComposite.getURI(); + return super.close(); + } +} -- cgit v1.2.3