Add Disk plugin

This commit is contained in:
peterdell 2018-12-30 16:32:52 +01:00
parent f28730cdc1
commit 2224425974
17 changed files with 460 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/AppleCommander-1.3.5.14.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.wudsn.ide.dsk</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -0,0 +1,17 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: WUDSN IDE Disk Images Plug-in
Bundle-SymbolicName: com.wudsn.ide.dsk;singleton:=true
Bundle-Version: 1.7.0.qualifier
Bundle-Activator: com.wudsn.ide.dsk.DiskPlugin
Bundle-Vendor: Peter Dell
Require-Bundle: org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ui.ide,
com.wudsn.ide.base;visibility:=reexport
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.webcodepro.applecommander.storage
Bundle-ClassPath: lib/AppleCommander-1.3.5.14.jar,
.

View File

@ -0,0 +1,5 @@
#
# Hardware: APPLE2
#
com.wudsn.ide.dsk.apple2.Apple2DiskImageFile.name=Apple II Disk Image
com.wudsn.ide.dsk.apple2.Apple2DiskImageEditor.name=Apple II Disk Image Editor

View File

@ -0,0 +1,5 @@
#
# Hardware: APPLE2
#
com.wudsn.ide.dsk.apple2.Apple2DiskImageFile.name=Apple II Disk Image
com.wudsn.ide.dsk.apple2.Apple2DiskImageEditor.name=Apple II Disk Image Editor

1
com.wudsn.ide.dsk/bin/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/com

View File

@ -0,0 +1,15 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
icons/,\
build.properties,\
src/,\
.classpath,\
.project,\
OSGI-INF/l10n/bundle.properties,\
OSGI-INF/,\
lib/AppleDos.dsk,\
lib/AppleCommander-1.3.5.14.jar

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.core.contenttype.contentTypes">
<content-type
file-extensions="dsk, po, nib"
id="com.wudsn.ide.dsk.apple2.Apple2DiskImageFile"
name="%com.wudsn.ide.dsk.apple2.Apple2DiskImageFile.name"
priority="normal">
</content-type>
</extension>
<extension
point="org.eclipse.ui.editors">
<editor
class="com.wudsn.ide.dsk.apple2.Apple2DiskImageEditor"
default="false"
icon="icons/editor-apple2-disk-image.gif"
id="com.wudsn.ide.dsk.apple2.Apple2DiskImageEditor"
name="%com.wudsn.ide.dsk.apple2.Apple2DiskImageEditor.name">
<contentTypeBinding
contentTypeId="com.wudsn.ide.dsk.apple2.Apple2DiskImageFile">
</contentTypeBinding>
</editor>
</extension>
</plugin>

View File

@ -0,0 +1,73 @@
package com.wudsn.ide.dsk;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* Copyright (C) 2009 - 2014 <a href="http://www.wudsn.com" target="_top">Peter Dell</a>
*
* This file is part of WUDSN IDE.
*
* WUDSN IDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* WUDSN IDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* The activator class controls the plug-in life cycle
*/
public class DiskPlugin extends AbstractUIPlugin {
/**
* The plugin id.
*/
public static final String PLUGIN_ID = "com.wudsn.ide.dsk"; //$NON-NLS-1$
/**
* The shared instance.
*/
private static DiskPlugin plugin;
/**
* The constructor
*/
public DiskPlugin() {
}
/**
* {@inheritDoc}
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/**
* {@inheritDoc}
*/
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Gets the shared plugin instance.
*
* @return The plug-in, not <code>null</code>.
*/
public static DiskPlugin getInstance() {
return plugin;
}
}

View File

@ -0,0 +1,40 @@
/**
* Copyright (C) 2009 - 2014 <a href="http://www.wudsn.com" target="_top">Peter Dell</a>
*
* This file is part of WUDSN IDE.
*
* WUDSN IDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* WUDSN IDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
*/
package com.wudsn.ide.dsk;
import org.eclipse.osgi.util.NLS;
/**
* Class which holds the localized text constants.
*
* @author Peter Dell
*/
public final class Texts extends NLS {
public static String MESSAGE_E100;
public static String MESSAGE_E101;
/**
* Initializes the constants.
*/
static {
NLS.initializeMessages(Texts.class.getName(), Texts.class);
}
}

View File

@ -0,0 +1,3 @@
MESSAGE_E100=The editor input is not a file in the file system.
MESSAGE_E101=The file is not a valid disk image.

View File

@ -0,0 +1,2 @@
MESSAGE_E100=Die Eingabe für den Editor ist keine Datei im Dateisystem.
MESSAGE_E101=Die Datei ist kein gültiges Diskettenimage.

View File

@ -0,0 +1,224 @@
/**
* Copyright (C) 2009 - 2014 <a href="http://www.wudsn.com" target="_top">Peter Dell</a>
*
* This file is part of WUDSN IDE.
*
* WUDSN IDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* WUDSN IDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
*/
package com.wudsn.ide.dsk.apple2;
import java.io.File;
import java.io.IOException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IPathEditorInput;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
import com.webcodepro.applecommander.storage.Disk;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.ui.swt.DiskExplorerTab;
import com.webcodepro.applecommander.ui.swt.DiskInfoTab;
import com.webcodepro.applecommander.ui.swt.DiskMapTab;
import com.webcodepro.applecommander.ui.swt.DiskWindow;
import com.webcodepro.applecommander.ui.swt.util.ImageManager;
import com.wudsn.ide.base.common.FileUtility;
import com.wudsn.ide.base.common.StringUtility;
import com.wudsn.ide.dsk.Texts;
/**
* Editor wrapper for AppleCommander. This version is tweaked to correctly run
* with the SWT version included in AppleCommander-1.3.5.jar.
*
* @author Peter Dell
* @since 1.6.3
*/
public final class Apple2DiskImageEditor extends EditorPart {
private static class DummyDiskWindow extends DiskWindow {
public DummyDiskWindow() {
super(null, null, null);
}
@Override
public void setStandardWindowTitle() {
}
}
private ImageManager imageManager;
private CTabFolder tabFolder;
private DiskExplorerTab diskExplorerTab;
private DiskMapTab[] diskMapTabs;
private DiskInfoTab diskInfoTab;
private String diskImageFilePath;
public Apple2DiskImageEditor() {
}
@Override
public void doSave(IProgressMonitor monitor) {
}
@Override
public void doSaveAs() {
}
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
// Clear fields.
File ioFile;
IFile iFile;
ioFile = null;
iFile = null;
setSite(site);
setInput(input);
String fileName = "";
if (input instanceof IFileEditorInput) {
// Input file found in Eclipse Workspace.
iFile = ((IFileEditorInput) input).getFile();
ioFile = iFile.getRawLocation().toFile();
fileName = iFile.getName();
} else if (input instanceof IPathEditorInput) {
// Input file is outside the Eclipse Workspace
IPathEditorInput pathEditorInput = (IPathEditorInput) input;
IPath path = pathEditorInput.getPath();
ioFile = path.toFile();
fileName = ioFile.getName();
} else {
// Not supported.
}
setPartName(fileName);
if (ioFile != null) {
diskImageFilePath = FileUtility.getCanonicalFile(ioFile).getPath();
} else {
diskImageFilePath = "";
}
}
@Override
public boolean isDirty() {
return false;
}
@Override
public boolean isSaveAsAllowed() {
return false;
}
@Override
public void createPartControl(Composite parent) {
FormattedDisk[] formattedDisks;
String errorText;
formattedDisks = new FormattedDisk[0];
errorText = null;
if (StringUtility.isEmpty(diskImageFilePath)) {
// ERROR: The editor input is not a file in the file system.
errorText = Texts.MESSAGE_E100;
} else {
try {
Disk disk = new Disk(diskImageFilePath);
formattedDisks = disk.getFormattedDisks();
if (formattedDisks.length == 0) {
// ERROOR: The file is not a valid disk image.
errorText = Texts.MESSAGE_E101;
}
} catch (IOException ex) {
errorText = ex.getMessage();
} catch (IllegalArgumentException ex) {
// Caused by
// com.webcodepro.applecommander.storage.Disk.isProdosFormat(Disk.java:379)
errorText = ex.getMessage();
} catch (ArrayIndexOutOfBoundsException ex) {
// Caused by
// com.webcodepro.applecommander.storage.Disk.isProdosFormat(Disk.java:379)
errorText = Texts.MESSAGE_E101;
}
}
if (errorText != null) {
Text text = new Text(parent, SWT.READ_ONLY);
text.setText(errorText);
return;
}
imageManager = new ImageManager(parent.getDisplay());
tabFolder = new CTabFolder(parent, SWT.BOTTOM);
diskExplorerTab = new DiskExplorerTab(tabFolder, formattedDisks,
imageManager, new DummyDiskWindow());
diskMapTabs = new DiskMapTab[formattedDisks.length];
for (int i = 0; i < formattedDisks.length; i++) {
if (formattedDisks[i].supportsDiskMap()) {
diskMapTabs[i] = new DiskMapTab(tabFolder, formattedDisks[i]);
}
}
diskInfoTab = new DiskInfoTab(tabFolder, formattedDisks);
tabFolder.setSelection(tabFolder.getItems()[0]);
}
@Override
public void setFocus() {
if (tabFolder != null) {
tabFolder.setFocus();
}
}
@Override
public void dispose() {
if (diskExplorerTab != null) {
diskExplorerTab.dispose();
diskExplorerTab = null;
}
if (diskMapTabs != null) {
for (int i = 0; i < diskMapTabs.length; i++) {
if (diskMapTabs[i] != null)
diskMapTabs[i].dispose();
}
diskMapTabs = null;
}
if (diskInfoTab != null) {
diskInfoTab.dispose();
diskInfoTab = null;
}
if (imageManager != null) {
imageManager.dispose();
imageManager = null;
}
}
}