Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
Issue #12 - Implements Image Export
Browse files Browse the repository at this point in the history
This implements the image export (save as) functionality.  It
migrates the toolbar actions away from the old ActionSet mechnanism
in favor of the Commands and Handlers framework.  This also allows
saving of the image as any filename the user wants, but it will
always export as PNG.
  • Loading branch information
kingargyle committed Oct 30, 2017
1 parent 6859b33 commit 4c9b317
Show file tree
Hide file tree
Showing 12 changed files with 342 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@
"trooper",
"guardian"
],
"name": "readyweapons",
"name": "Ready Weapons",
"cost": 0,
"limit": 1
}
Expand Down Expand Up @@ -1604,13 +1604,13 @@
},
{
"card": {
"iaspecName": "wookierage",
"iaspecName": "wookieerage",
"faction": "any",
"imageurl": "http://tabletopadmiral.com/static/main/images/Chewbacca/Wookie%20Rage.png",
"restrictions": [
"wookiee"
],
"name": "Wookie Rage",
"name": "Wookiee Rage",
"cost": 2,
"limit": 1
}
Expand Down Expand Up @@ -2229,6 +2229,21 @@
"cost": 0,
"limit": 1
}
},
{
"card": {
"iaspecName": "armedescort",
"faction": "any",
"imageurl": "http://tabletopadmiral.com/static/main/images/Heart%20of%20the%20Empire/Armed%20Escort.png",
"restrictions": [
"vehicle",
"droid"
],
"name": "Armed Escort",
"cost": 1,
"limit": 1
}
}

]
}
1 change: 0 additions & 1 deletion bundles/us.nineworlds.xstreamer/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Import-Package: org.apache.commons.lang,
Bundle-Activator: us.nineworlds.xstreamer.Activator
Bundle-ActivationPolicy: lazy
Export-Package: schemas,
uky.article.imageviewer.actions,
uky.article.imageviewer.views,
us.nineworlds.xstreamer,
us.nineworlds.xstreamer.eventbus,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
153 changes: 84 additions & 69 deletions bundles/us.nineworlds.xstreamer/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,41 @@
id="us.nineworlds.xstreamer.donate"
name="Donate">
</command>
<command
defaultHandler="uky.article.imageviewer.handlers.ImageViewOpenHandler"
id="us.nineworlds.xstreamer.imageview.open"
name="Open">
</command>
<command
defaultHandler="uky.article.imageviewer.handlers.ImageViewFitHandler"
id="us.nineworlds.xstreamer.imageview.fit"
name="Fit">
</command>
<command
defaultHandler="uky.article.imageviewer.handlers.ImageViewRotateHandler"
id="us.nineworlds.xstreamer.imageview.rotate"
name="Rotate">
</command>
<command
defaultHandler="uky.article.imageviewer.handlers.ImageViewSaveAsHandler"
id="us.nineworlds.xstreamer.imageview.saveas"
name="Save As">
</command>
<command
defaultHandler="uky.article.imageviewer.handlers.ImageViewShowOriginalHandler"
id="us.nineworlds.xstreamer.imageview.originalsize"
name="Original Size">
</command>
<command
defaultHandler="uky.article.imageviewer.handlers.ImageViewZoomInHandler"
id="us.nineworlds.xstreamer.imageview.zoomin"
name="Zoom In">
</command>
<command
defaultHandler="uky.article.imageviewer.handlers.ImageViewZoomOutHandler"
id="us.nineworlds.xstreamer.imageview.zoomout"
name="Zoom Out">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
Expand All @@ -263,75 +298,6 @@
commandId="us.nineworlds.xstreamer.donate">
</handler>
</extension>

<extension
point="org.eclipse.ui.viewActions">
<viewContribution
targetID="us.nineworlds.xstreamer.imageview"
id="uky.article.imageviewer.views.ImageView.pushbutton">
<!-- Open button -->
<action
label="open"
icon="icons/Open16.gif"
tooltip="Open image"
class="uky.article.imageviewer.actions.PushActionDelegate"
toolbarPath="push_group"
enablesFor="*"
id="toolbar.open">
<!--id="org.eclipse.ui.file.open"-->
</action>
<!-- Rotation button -->
<action
label="Rotate"
icon="icons/Rotate16.gif"
tooltip="Rotate"
class="uky.article.imageviewer.actions.PushActionDelegate"
toolbarPath="push_group"
enablesFor="*"
id="toolbar.rotate">
</action>
<!-- Fit button -->
<action
label="FitWindow"
icon="icons/Fit16.gif"
tooltip="Fit window"
class="uky.article.imageviewer.actions.PushActionDelegate"
toolbarPath="push_group"
enablesFor="*"
id="toolbar.fit">
</action>
<!-- Original button -->
<action
label="OriginalSize"
icon="icons/Original16.gif"
tooltip="Original size"
class="uky.article.imageviewer.actions.PushActionDelegate"
toolbarPath="push_group"
enablesFor="*"
id="toolbar.original">
</action>
<!-- ZoomIn button -->
<action
label="ZoomIn"
icon="icons/ZoomIn16.gif"
tooltip="Zoom in"
class="uky.article.imageviewer.actions.PushActionDelegate"
toolbarPath="push_group"
enablesFor="*"
id="toolbar.zoomin">
</action>
<!-- ZoomOut button -->
<action
label="ZoomOut"
icon="icons/ZoomOut16.gif"
tooltip="Zoom out"
class="uky.article.imageviewer.actions.PushActionDelegate"
toolbarPath="push_group"
enablesFor="*"
id="toolbar.zoomout">
</action>
</viewContribution>
</extension>
<extension
point="org.eclipse.core.runtime.adapters">
<factory
Expand All @@ -354,4 +320,53 @@
class="us.nineworlds.xstreamer.Startup">
</startup>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="toolbar:us.nineworlds.xstreamer.imageview">
<command
commandId="us.nineworlds.xstreamer.imageview.open"
icon="icons/Open16.gif"
style="push"
tooltip="Open">
</command>
<command
commandId="us.nineworlds.xstreamer.imageview.zoomin"
icon="icons/ZoomIn16.gif"
style="push"
tooltip="Zoom In">
</command>
<command
commandId="us.nineworlds.xstreamer.imageview.zoomout"
icon="icons/ZoomOut16.gif"
style="push"
tooltip="Zoom Out">
</command>
<command
commandId="us.nineworlds.xstreamer.imageview.zoomfit"
icon="icons/Fit16.gif"
style="push"
tooltip="Fit">
</command>
<command
commandId="us.nineworlds.xstreamer.imageview.rotate"
icon="icons/Rotate16.gif"
style="push"
tooltip="Rotate">
</command>
<command
commandId="us.nineworlds.xstreamer.imageview.originalsize"
icon="icons/Original16.gif"
style="push"
tooltip="Original Size">
</command>
<command
commandId="us.nineworlds.xstreamer.imageview.saveas"
icon="icons/saveas_edit.gif"
style="push"
tooltip="Save As">
</command>
</menuContribution>
</extension>
</plugin>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package uky.article.imageviewer.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;

import uky.article.imageviewer.views.ImageView;
import uky.article.imageviewer.views.SWTImageCanvas;

public class ImageViewFitHandler extends AbstractHandler implements IHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
ImageView imageView = (ImageView) activePart;
SWTImageCanvas imageCanvas = imageView.imageCanvas;
if (imageCanvas == null) {
return null;
}

imageCanvas.fitCanvas();

return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package uky.article.imageviewer.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;

import uky.article.imageviewer.views.ImageView;
import uky.article.imageviewer.views.SWTImageCanvas;

public class ImageViewOpenHandler extends AbstractHandler implements IHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
ImageView imageView = (ImageView) activePart;
SWTImageCanvas imageCanvas = imageView.imageCanvas;

imageCanvas.onFileOpen();

return null;
}

}
Loading

0 comments on commit 4c9b317

Please sign in to comment.