Skip to content

Commit

Permalink
rbeased to master fixed merge problems
Browse files Browse the repository at this point in the history
Change-Id: Id68b57afed3b376a6f18ad2ce20a976a7d27c666
Signed-off-by: Frank Gasdorf <[email protected]>
  • Loading branch information
fgdrf committed Jan 13, 2022
1 parent 149f6d9 commit 32c70c1
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.locationtech.udig.project.tests.support.MapTests;
import org.locationtech.udig.project.tests.ui.ViewPart1;
import org.locationtech.udig.project.ui.ApplicationGIS;
import org.locationtech.udig.project.ui.internal.MapEditor;
import org.locationtech.udig.project.ui.internal.MapEditorWithPalette;
import org.locationtech.udig.project.ui.internal.MapPart;
import org.locationtech.udig.ui.tests.support.UDIGTestUtil;
import org.opengis.feature.simple.SimpleFeature;
Expand Down Expand Up @@ -153,7 +153,7 @@ public void testRestoreEditor() throws Exception {
TestIssue issue = new TestIssue() {
@Override
public String getEditorID() {
return MapEditor.ID;
return MapEditorWithPalette.ID;

}

Expand All @@ -165,7 +165,7 @@ public IEditorInput getEditorInput() {
IssueHandler handler = IssueHandler.createHandler(issue);
handler.restoreEditor();

assertEquals(MapEditor.class,
assertEquals(MapEditorWithPalette.class,
getActiveWindow().getActivePage().getActiveEditor().getClass());
assertEquals(map, ((MapPart) getActiveWindow().getActivePage().getActiveEditor()).getMap());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
import org.locationtech.udig.project.tests.support.MapTests;
import org.locationtech.udig.project.tests.ui.ViewPart1;
import org.locationtech.udig.project.ui.ApplicationGIS;
import org.locationtech.udig.project.ui.internal.MapEditor;
import org.locationtech.udig.project.ui.internal.MapEditorWithPalette;
import org.locationtech.udig.ui.tests.support.UDIGTestUtil;
import org.opengis.feature.simple.SimpleFeature;

Expand Down Expand Up @@ -332,7 +332,7 @@ class FixIssue extends TestIssue {

@Override
public String getEditorID() {
return MapEditor.ID;
return MapEditorWithPalette.ID;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.locationtech.udig.project.ui.internal.ApplicationGISInternal;
import org.locationtech.udig.project.ui.internal.FeatureEditorLoader;
import org.locationtech.udig.project.ui.internal.MapEditorInput;
import org.locationtech.udig.project.ui.internal.MapEditor;
import org.locationtech.udig.project.ui.internal.MapEditorWithPalette;
import org.locationtech.udig.project.ui.internal.tool.ToolContext;
import org.locationtech.udig.ui.ProgressManager;
import org.opengis.feature.simple.SimpleFeature;
Expand Down Expand Up @@ -113,7 +113,7 @@ public void setId(String id) {

@Override
public String getEditorID() {
return MapEditor.ID;
return MapEditorWithPalette.ID;
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions plugins/org.locationtech.udig.project.ui.editor/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<extension
point="org.eclipse.ui.editors">
<editor
class="org.locationtech.udig.project.ui.internal.MapEditorWithPalette"
contributorClass="org.locationtech.udig.project.ui.internal.MapEditorActionBarContributor"
default="true"
icon="icons/obj16/map_obj.gif"
id="org.locationtech.udig.project.ui.mapEditor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.locationtech.udig.project.internal.Map;
import org.locationtech.udig.project.ui.ApplicationGIS;
import org.locationtech.udig.project.ui.internal.ApplicationGISInternal;
import org.locationtech.udig.project.ui.internal.MapEditor;
import org.locationtech.udig.project.ui.internal.MapEditorWithPalette;
import org.locationtech.udig.project.ui.internal.MapPart;
import org.locationtech.udig.ui.IDropAction;
import org.locationtech.udig.ui.IDropHandlerListener;
Expand All @@ -61,7 +61,7 @@ public void setUp() throws Exception {

UDIGControlDropListener dropper = UDIGDragDropUtilities.getEditorDropListener();
handler = dropper.getHandler();
handler.setTarget(new MapEditor());
handler.setTarget(new MapEditorWithPalette());
done = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
Expand Down Expand Up @@ -135,7 +135,7 @@
* @version $Revision: 1.9 $
*/
// TODO: Rename this to MapEditor to prevent code bloat / code duplication
public class MapEditor extends GraphicalEditorWithFlyoutPalette
public class MapEditorWithPalette extends GraphicalEditorWithFlyoutPalette
implements IDropTargetProvider, IAdaptable, MapEditorPart {

public static final int STATUS_LINE_HEIGHT;
Expand Down Expand Up @@ -164,7 +164,7 @@ public class MapEditor extends GraphicalEditorWithFlyoutPalette

final StatusLineManager statusLineManager = new StatusLineManager();

private MapEditorSite mapEditorSite;
private MapSite mapSite;

private boolean dirty = false;

Expand All @@ -191,7 +191,7 @@ public class MapEditor extends GraphicalEditorWithFlyoutPalette
/**
* Creates a new MapViewport object.
*/
public MapEditor() {
public MapEditorWithPalette() {
// Make sure the featureEditorProcessor has been started.
// This will load all the tools so we can use them
ProjectUIPlugin.getDefault().getFeatureEditProcessor();
Expand Down Expand Up @@ -297,7 +297,7 @@ public void changed(final MapEvent event) {
return;
}

MapEditor.this.composite.getDisplay().asyncExec(new Runnable() {
MapEditorWithPalette.this.composite.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
switch (event.getType()) {
Expand Down Expand Up @@ -380,8 +380,8 @@ public boolean handlePreShutdownException(Throwable t, boolean forced) {
@Override
public boolean preShutdown(IProgressMonitor monitor, IWorkbench workbench, boolean forced)
throws Exception {
monitor.beginTask("Saving Map Editor", 3); //$NON-NLS-1$
save(new SubProgressMonitor(monitor, 1));
monitor.beginTask("Saving Map Editor", 3);
save(SubMonitor.convert(monitor, 1));
if (dirty) {
if (!forced) {
return false;
Expand Down Expand Up @@ -788,8 +788,8 @@ protected void createGraphicalViewer(Composite parent) {
this.replaceableSelectionProvider = new ReplaceableSelectionProvider();
getSite().setSelectionProvider(replaceableSelectionProvider);
runMapOpeningInterceptor(getMap());
mapEditorSite = new MapEditorSite(super.getSite(), this);
final IContributionManager statusBar = mapEditorSite.getActionBars().getStatusLineManager();
mapSite = new MapSite(super.getSite(), this);
final IContributionManager statusBar = mapSite.getActionBars().getStatusLineManager();

scaleContributionItem = new ScaleRatioLabel(this);
scaleContributionItem.setVisible(true);
Expand Down Expand Up @@ -876,8 +876,8 @@ public void menuAboutToShow(IMenuManager mgr) {
contextMenu.add(tm.getBACKWARD_HISTORYAction());
contextMenu.add(tm.getFORWARD_HISTORYAction());
contextMenu.add(new Separator());
contextMenu.add(tm.getCOPYAction(MapEditor.this));
contextMenu.add(tm.getPASTEAction(MapEditor.this));
contextMenu.add(tm.getCOPYAction(MapEditorWithPalette.this));
contextMenu.add(tm.getPASTEAction(MapEditorWithPalette.this));
contextMenu.add(tm.getDELETEAction());

/**
Expand Down Expand Up @@ -1001,10 +1001,10 @@ public SubActionBars2 getActionbar() {
IPartListener2 partlistener = new IPartListener2() {
@Override
public void partActivated(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == MapEditor.this) {
if (partRef.getPart(false) == MapEditorWithPalette.this) {
registerFeatureFlasher();
IToolManager tools = ApplicationGIS.getToolManager();
tools.setCurrentEditor(MapEditor.this);
tools.setCurrentEditor(MapEditorWithPalette.this);
}
}

Expand All @@ -1015,7 +1015,7 @@ public void partBroughtToTop(IWorkbenchPartReference partRef) {

@Override
public void partClosed(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == MapEditor.this) {
if (partRef.getPart(false) == MapEditorWithPalette.this) {
deregisterFeatureFlasher();
visible = false;
}
Expand All @@ -1033,15 +1033,15 @@ public void partOpened(IWorkbenchPartReference partRef) {

@Override
public void partHidden(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == MapEditor.this) {
if (partRef.getPart(false) == MapEditorWithPalette.this) {
deregisterFeatureFlasher();
visible = false;
}
}

@Override
public void partVisible(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == MapEditor.this) {
if (partRef.getPart(false) == MapEditorWithPalette.this) {
registerFeatureFlasher();
visible = true;
}
Expand Down Expand Up @@ -1115,15 +1115,15 @@ public void setSelectionProvider(IMapEditorSelectionProvider selectionProvider)
}

@Override
public MapEditorSite getMapEditorSite() {
return mapEditorSite;
public MapSite getMapSite() {
return mapSite;
}

private class FlashFeatureListener implements ISelectionListener {

@Override
public void selectionChanged(IWorkbenchPart part, final ISelection selection) {
if (part == MapEditor.this || getSite().getPage().getActivePart() != part
if (part == MapEditorWithPalette.this || getSite().getPage().getActivePart() != part
|| selection instanceof IBlockingSelection)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@

/**
* Save strategy for Map Palette
*
*
* @author Jody Garnett
* @since 1.3.0
* @version 1.3.0
*/
public final class MapPaletteSaveStrategy extends CatalogExport {
private final ExportResourceSelectionState state;
private MapEditor editor;
private MapEditorWithPalette editor;

public MapPaletteSaveStrategy(ExportResourceSelectionState state, MapEditor editor) {
public MapPaletteSaveStrategy(ExportResourceSelectionState state, MapEditorWithPalette editor) {
super(false);
this.state = state;
this.editor = editor;
Expand Down Expand Up @@ -115,7 +115,7 @@ private Collection<Layer> toLayers(Layer found,
Collection<IGeoResource> exported) {
LayerFactory layerFactory = MapPaletteSaveStrategy.this.editor
.getMap().getLayerFactory();
Collection<Layer> newLayers = new ArrayList<Layer>();
Collection<Layer> newLayers = new ArrayList<>();

for (IGeoResource exportedResource : exported) {
try {
Expand All @@ -138,5 +138,5 @@ private Collection<Layer> toLayers(Layer found,
catalogExportWizard.setSelectExportedInCatalog(false);
return catalogExportWizard;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
*
*
*/
package org.locationtech.udig.project.ui.internal;

Expand All @@ -17,28 +17,29 @@

/**
* Save strategy for Map Palette
*
*
* @author Jody Garnett
* @since 1.3.0
* @version 1.3.0
*/
class SaveMapPaletteRunnable implements Runnable{
private final MapEditor mapEditor;
private final MapEditorWithPalette mapEditor;
private final boolean[] success;


public SaveMapPaletteRunnable(MapEditor mapEditor, boolean[] success) {

public SaveMapPaletteRunnable(MapEditorWithPalette mapEditor, boolean[] success) {
super();
this.mapEditor = mapEditor;
this.success = success;
}

private enum Result{NO_TEMP_LAYERS, EXPORT_WIZARD_RUNNING};
@Override
public void run() {
try{

EditManager editManagerInternal = mapEditor.getMap().getEditManagerInternal();

SaveMapPaletteRunnable.Result result = saveTemporaryLayers();
if( result == Result.NO_TEMP_LAYERS ){
editManagerInternal.commitTransaction();
Expand All @@ -54,27 +55,27 @@ public void run() {
}

private SaveMapPaletteRunnable.Result saveTemporaryLayers( ) {
List<IGeoResource> resources=new ArrayList<IGeoResource>();
List<IGeoResource> resources=new ArrayList<>();
for( ILayer layer : mapEditor.getMap().getMapLayers() ) {
if( layer.hasResource(ITransientResolve.class) )
resources.addAll(layer.getGeoResources());
}

if( resources.isEmpty() ){
return Result.NO_TEMP_LAYERS;
}

final StructuredSelection selection = new StructuredSelection(resources);
final ExportResourceSelectionState layerState = new ExportResourceSelectionState(selection);

CatalogExport exp = new MapPaletteSaveStrategy(layerState, mapEditor);

// open the export dialog
exp.open();

// Since dialog is opened after this returns return cancelled and we'll make sure the MapSaveStrategy will clear the
// dirty state if the export takes place.

return Result.EXPORT_WIZARD_RUNNING;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void run(IProgressMonitor monitor)
if (!proceed) {
return;
}
int numEditors = p.getInt(MapEditor.ID);
int numEditors = p.getInt(MapEditorWithPalette.ID);
if (numEditors == 0)
return;
final String title = Messages.StartupOpenMaps_openMapDialogTitle;
Expand All @@ -149,13 +149,13 @@ public void run(IProgressMonitor monitor)
*/
private void openLastOpenMaps(IProgressMonitor monitor) {
IPreferenceStore p = ProjectUIPlugin.getDefault().getPreferenceStore();
int numEditors = p.getInt(MapEditor.ID);
int numEditors = p.getInt(MapEditorWithPalette.ID);
monitor.beginTask(Messages.StartupOpenMaps_openMapDialogTitle, numEditors * 2 + 2);
p.setValue(MapEditor.ID, 0);
p.setValue(MapEditorWithPalette.ID, 0);

for (int i = 0; i < numEditors; i++) {
monitor.worked(1);
String id = MapEditor.ID + ":" + i; //$NON-NLS-1$
String id = MapEditorWithPalette.ID + ":" + i; //$NON-NLS-1$
String name = p.getString(id);
if (name == null || name.equals("")) //$NON-NLS-1$
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.eclipse.swt.graphics.Image;
import org.locationtech.udig.internal.ui.operations.OperationCategory;
import org.locationtech.udig.project.ui.ApplicationGIS;
import org.locationtech.udig.project.ui.internal.MapEditor;
import org.locationtech.udig.project.ui.internal.MapEditorWithPalette;
import org.locationtech.udig.project.ui.internal.MapPart;
import org.locationtech.udig.project.ui.internal.MapToolEntry;
import org.locationtech.udig.project.ui.internal.ProjectUIPlugin;
Expand Down Expand Up @@ -123,8 +123,8 @@ public void setChecked(boolean checked) {
ToolManager tools = (ToolManager) ApplicationGIS.getToolManager();
MapPart currentEditor = tools.currentEditor;
if (currentEditor != null) {
if (currentEditor instanceof MapEditor) {
MapEditor editor2 = (MapEditor) currentEditor;
if (currentEditor instanceof MapEditorWithPalette) {
MapEditorWithPalette editor2 = (MapEditorWithPalette) currentEditor;

MapEditDomain editDomain = editor2.getEditDomain();

Expand Down
Loading

0 comments on commit 32c70c1

Please sign in to comment.