Commit c73b85c4 authored by Ubbo Veentjer's avatar Ubbo Veentjer
Browse files

add preferences page

git-svn-id: https://textgridlab.org/svn/textgrid/trunk/lab/sadepublish@11484 7c539038-3410-0410-b1ec-0f2a7bf1c452
parent 61d95d59
......@@ -76,5 +76,13 @@
file="contexts.xml">
</contexts>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
class="info.textgrid.lab.sadepublish.preferences.PluginPreferencePage"
id="info.textgrid.lab.sadepublish.preferences"
name="Sade Publisher">
</page>
</extension>
</plugin>
/*
* #%L
* info.textgrid.lab.sadepublish
* %%
* Copyright (C) 2011 TextGrid Consortium (http://www.textgrid.de)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
package info.textgrid.lab.sadepublish.preferences;
import info.textgrid.lab.sadepublish.Activator;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
public class PluginPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage{
public static String sadeUrl_id = "sade_instance_url";
@Override
protected void createFieldEditors() {
addField(new StringFieldEditor(sadeUrl_id, "URL for drag and drop to sade instance", getFieldEditorParent()));
}
@Override
public void init(IWorkbench workbench) {
setPreferenceStore(Activator.getDefault().getPreferenceStore());
}
}
/*
* #%L
* info.textgrid.lab.sadepublish
* %%
* Copyright (C) 2011 TextGrid Consortium (http://www.textgrid.de)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
package info.textgrid.lab.sadepublish.preferences;
import info.textgrid.lab.sadepublish.Activator;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
public class PluginPreferencePageInitializer extends AbstractPreferenceInitializer{
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(PluginPreferencePage.sadeUrl_id, "http://localhost:8080/tgwp/dnd.html");
}
}
......@@ -23,48 +23,18 @@ package info.textgrid.lab.sadepublish.views;
import info.textgrid.lab.authn.RBACSession;
import info.textgrid.lab.sadepublish.Activator;
import info.textgrid.lab.sadepublish.preferences.PluginPreferencePage;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.*;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.*;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.DragDetectEvent;
import org.eclipse.swt.events.DragDetectListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.*;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
/**
* This sample class demonstrates how to plug-in a new
* workbench view. The view shows data obtained from the
* model. The sample creates a dummy model on the fly,
* but a real implementation would connect to the model
* available either in this or another plug-in (e.g. the workspace).
* The view is connected to the model using a content provider.
* <p>
* The view uses a label provider to define how model
* objects should be presented in the view. Each
* view can present the same model objects using
* different labels and icons, if needed. Alternatively,
* a single label provider can be shared between views
* in order to ensure that objects of the same type are
* presented in the same way everywhere.
* <p>
*/
public class SadePublishView extends ViewPart {
......@@ -80,7 +50,15 @@ public class SadePublishView extends ViewPart {
return;
}
spBrowser.setUrl("http://localhost:8080/tgwp/dnd.html");
String url = Platform.getPreferencesService().getString(Activator.PLUGIN_ID, PluginPreferencePage.sadeUrl_id, "", null);
if(url.equals("")) {
spBrowser.setText("No publish destination, please set one with Window->Preferences->Sade Publisher");
return;
}
spBrowser.setUrl(url);
spBrowser.addProgressListener(new ProgressListener() {
public void changed(ProgressEvent arg0) {}
public void completed(ProgressEvent arg0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment