From ae0cb5055ab0e8db1346b10e2170e209b046a904 Mon Sep 17 00:00:00 2001 From: Chan Le Duc <chan.leduc@univ-paris13.fr> Date: Mon, 22 Jun 2009 15:14:03 +0000 Subject: [PATCH] --Added classes for eclipse interface --- .../exmo/align/plugin/neontk/AlignAction.java | 6 + .../plugin/neontk/AlignFormLayoutFactory.java | 217 +++++ .../neontk/AlignFormSectionFactory.java | 210 +++++ .../exmo/align/plugin/neontk/AlignView.java | 861 +++++++++++++++++- .../align/plugin/neontk/AlignmentPlugin.java | 2 +- .../exmo/align/plugin/neontk/OnlineAlign.java | 9 +- .../align/plugin/neontk/OnlineDialog.java | 140 +++ .../align/plugin/neontk/SWTInterface.java | 10 +- .../exmo/align/plugin/neontk/WSDialog.java | 157 ++++ 9 files changed, 1579 insertions(+), 33 deletions(-) create mode 100644 plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignFormLayoutFactory.java create mode 100644 plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignFormSectionFactory.java create mode 100644 plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/OnlineDialog.java create mode 100644 plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/WSDialog.java diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignAction.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignAction.java index d28c5843..5db41872 100755 --- a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignAction.java +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignAction.java @@ -26,6 +26,7 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; //import org.eclipse.ui.internal.WorkbenchWindow; @@ -63,7 +64,12 @@ public class AlignAction implements IWorkbenchWindowActionDelegate { * @see IWorkbenchWindowActionDelegate#run */ public void run(IAction action) { + //MessageDialog.openInformation( + // window.getShell(), + // "Alignment Plug-in, Version 1.0.1", + // "Hello, UPDATED Eclipse world"); IViewPart view = (IViewPart)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(AlignView.ID); + try{ window.getActivePage().showView(AlignView.ID); } diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignFormLayoutFactory.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignFormLayoutFactory.java new file mode 100644 index 00000000..fb155950 --- /dev/null +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignFormLayoutFactory.java @@ -0,0 +1,217 @@ +/* + * $Id: View.java 860 2008-10-17 07:43:35Z cleduc $ + * + * Copyright (C) INRIA, 2007-2008 + * + * 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 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.plugin.neontk; + +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.forms.widgets.TableWrapLayout; +import org.eclipse.swt.SWT; + +public class AlignFormLayoutFactory { + + public static final int DEFAULT_CLEAR_MARGIN = 10; + public static final int CONTROL_HORIZONTAL_INDENT = 3; + public static final int FORM_BODY_MARGIN_TOP = 12; + public static final int FORM_BODY_MARGIN_BOTTOM = 12; + public static final int FORM_BODY_MARGIN_LEFT = 6; + public static final int FORM_BODY_MARGIN_RIGHT = 6; + public static final int FORM_BODY_HORIZONTAL_SPACING = 8; + public static final int FORM_BODY_VERTICAL_SPACING = 5; + public static final int FORM_BODY_MARGIN_HEIGHT = 0; + public static final int FORM_BODY_MARGIN_WIDTH = 0; + public static final int SECTION_CLIENT_MARGIN_TOP = 10; + public static final int SECTION_CLIENT_MARGIN_BOTTOM = 10; + public static final int SECTION_CLIENT_MARGIN_LEFT = 6; + public static final int SECTION_CLIENT_MARGIN_RIGHT = 6; + public static final int SECTION_CLIENT_HORIZONTAL_SPACING = 8; + public static final int SECTION_CLIENT_VERTICAL_SPACING = 8; + public static final int SECTION_CLIENT_MARGIN_HEIGHT = 0; + public static final int SECTION_CLIENT_MARGIN_WIDTH = 0; + public static final int SECTION_HEADER_VERTICAL_SPACING = 6; + public static final int CLEAR_MARGIN_TOP = DEFAULT_CLEAR_MARGIN; + public static final int CLEAR_MARGIN_BOTTOM = DEFAULT_CLEAR_MARGIN; + public static final int CLEAR_MARGIN_LEFT = DEFAULT_CLEAR_MARGIN; + public static final int CLEAR_MARGIN_RIGHT = DEFAULT_CLEAR_MARGIN; + public static final int CLEAR_HORIZONTAL_SPACING = 8; + public static final int CLEAR_VERTICAL_SPACING = 8; + public static final int CLEAR_MARGIN_HEIGHT = 0; + public static final int CLEAR_MARGIN_WIDTH = 0; + public static final int FORM_PANE_MARGIN_TOP = 0; + public static final int FORM_PANE_MARGIN_BOTTOM = 0; + public static final int FORM_PANE_MARGIN_LEFT = 0; + public static final int FORM_PANE_MARGIN_RIGHT = 0; + public static final int FORM_PANE_HORIZONTAL_SPACING = FORM_BODY_HORIZONTAL_SPACING; + public static final int FORM_PANE_VERTICAL_SPACING = FORM_BODY_VERTICAL_SPACING; + public static final int FORM_PANE_MARGIN_HEIGHT = 0; + public static final int FORM_PANE_MARGIN_WIDTH = 0; + + private AlignFormLayoutFactory() { + // empty implementation + } + + //public static FillLayout createFormFillLayout( ) { + // FillLayout layout = new FillLayout(); + // layout.type = SWT.VERTICAL; + // return layout; + //} + + public static void configureLayout(Control c, FormAttachment left, + FormAttachment top, FormAttachment right, FormAttachment bottom) { + FormData fd = new FormData(); + if (left != null) { + fd.left = left; + } + if (top != null) { + fd.top = top; + } + if (right != null) { + fd.right = right; + } + if (bottom != null) { + fd.bottom = bottom; + } + c.setLayoutData(fd); + } + + public static GridLayout createFormGridLayout( final boolean makeColumnsEqualWidth, + final int numColumns ) { + GridLayout layout = new GridLayout(); + layout.marginHeight = FORM_BODY_MARGIN_HEIGHT; + layout.marginWidth = FORM_BODY_MARGIN_WIDTH; + layout.marginTop = FORM_BODY_MARGIN_TOP; + layout.marginBottom = FORM_BODY_MARGIN_BOTTOM; + layout.marginLeft = FORM_BODY_MARGIN_LEFT; + layout.marginRight = FORM_BODY_MARGIN_RIGHT; + layout.horizontalSpacing = FORM_BODY_HORIZONTAL_SPACING; + layout.verticalSpacing = FORM_BODY_VERTICAL_SPACING; + layout.makeColumnsEqualWidth = makeColumnsEqualWidth; + layout.numColumns = numColumns; + return layout; + } + + public static GridLayout createClearGridLayout( final boolean makeColumnsEqualWidth, + final int numColumns ) { + GridLayout layout = new GridLayout(); + layout.marginHeight = CLEAR_MARGIN_HEIGHT; + layout.marginWidth = CLEAR_MARGIN_WIDTH; + layout.marginTop = CLEAR_MARGIN_TOP; + layout.marginBottom = CLEAR_MARGIN_BOTTOM; + layout.marginLeft = CLEAR_MARGIN_LEFT; + layout.marginRight = CLEAR_MARGIN_RIGHT; + layout.horizontalSpacing = CLEAR_HORIZONTAL_SPACING; + layout.verticalSpacing = CLEAR_VERTICAL_SPACING; + layout.makeColumnsEqualWidth = makeColumnsEqualWidth; + layout.numColumns = numColumns; + return layout; + } + + public static TableWrapLayout createFormTableWrapLayout( final boolean makeColumnsEqualWidth, + final int numColumns ) { + TableWrapLayout layout = new TableWrapLayout(); + layout.topMargin = FORM_BODY_MARGIN_TOP; + layout.bottomMargin = FORM_BODY_MARGIN_BOTTOM; + layout.leftMargin = FORM_BODY_MARGIN_LEFT; + layout.rightMargin = FORM_BODY_MARGIN_RIGHT; + layout.horizontalSpacing = FORM_BODY_HORIZONTAL_SPACING; + layout.verticalSpacing = FORM_BODY_VERTICAL_SPACING; + layout.makeColumnsEqualWidth = makeColumnsEqualWidth; + layout.numColumns = numColumns; + return layout; + } + + public static TableWrapLayout createFormPaneTableWrapLayout( final boolean makeColumnsEqualWidth, + final int numColumns ) { + TableWrapLayout layout = new TableWrapLayout(); + layout.topMargin = FORM_PANE_MARGIN_TOP; + layout.bottomMargin = FORM_PANE_MARGIN_BOTTOM; + layout.leftMargin = FORM_PANE_MARGIN_LEFT; + layout.rightMargin = FORM_PANE_MARGIN_RIGHT; + layout.horizontalSpacing = FORM_PANE_HORIZONTAL_SPACING; + layout.verticalSpacing = FORM_PANE_VERTICAL_SPACING; + layout.makeColumnsEqualWidth = makeColumnsEqualWidth; + layout.numColumns = numColumns; + return layout; + } + + public static GridLayout createFormPaneGridLayout( final boolean makeColumnsEqualWidth, + final int numColumns ) { + GridLayout layout = new GridLayout(); + layout.marginHeight = FORM_PANE_MARGIN_HEIGHT; + layout.marginWidth = FORM_PANE_MARGIN_WIDTH; + layout.marginTop = FORM_PANE_MARGIN_TOP; + layout.marginBottom = FORM_PANE_MARGIN_BOTTOM; + layout.marginLeft = FORM_PANE_MARGIN_LEFT; + layout.marginRight = FORM_PANE_MARGIN_RIGHT; + layout.horizontalSpacing = FORM_PANE_HORIZONTAL_SPACING; + layout.verticalSpacing = FORM_PANE_VERTICAL_SPACING; + layout.makeColumnsEqualWidth = makeColumnsEqualWidth; + layout.numColumns = numColumns; + return layout; + } + + public static TableWrapLayout createClearTableWrapLayout( final boolean makeColumnsEqualWidth, + final int numColumns ) { + TableWrapLayout layout = new TableWrapLayout(); + layout.topMargin = CLEAR_MARGIN_TOP; + layout.bottomMargin = CLEAR_MARGIN_BOTTOM; + layout.leftMargin = CLEAR_MARGIN_LEFT; + layout.rightMargin = CLEAR_MARGIN_RIGHT; + layout.horizontalSpacing = CLEAR_HORIZONTAL_SPACING; + layout.verticalSpacing = CLEAR_VERTICAL_SPACING; + layout.makeColumnsEqualWidth = makeColumnsEqualWidth; + layout.numColumns = numColumns; + return layout; + } + + public static GridLayout createSectionClientGridLayout( final boolean makeColumnsEqualWidth, + final int numColumns ) { + GridLayout layout = new GridLayout(); + layout.marginHeight = SECTION_CLIENT_MARGIN_HEIGHT; + layout.marginWidth = SECTION_CLIENT_MARGIN_WIDTH; + layout.marginTop = SECTION_CLIENT_MARGIN_TOP; + layout.marginBottom = SECTION_CLIENT_MARGIN_BOTTOM; + layout.marginLeft = SECTION_CLIENT_MARGIN_LEFT; + layout.marginRight = SECTION_CLIENT_MARGIN_RIGHT; + layout.horizontalSpacing = SECTION_CLIENT_HORIZONTAL_SPACING; + layout.verticalSpacing = SECTION_CLIENT_VERTICAL_SPACING; + layout.makeColumnsEqualWidth = makeColumnsEqualWidth; + layout.numColumns = numColumns; + return layout; + } + + public static TableWrapLayout createSectionClientTableWrapLayout( final boolean makeColumnsEqualWidth, + final int numColumns ) { + TableWrapLayout layout = new TableWrapLayout(); + layout.topMargin = SECTION_CLIENT_MARGIN_TOP; + layout.bottomMargin = SECTION_CLIENT_MARGIN_BOTTOM; + layout.leftMargin = SECTION_CLIENT_MARGIN_LEFT; + layout.rightMargin = SECTION_CLIENT_MARGIN_RIGHT; + layout.horizontalSpacing = SECTION_CLIENT_HORIZONTAL_SPACING; + layout.verticalSpacing = SECTION_CLIENT_VERTICAL_SPACING; + layout.makeColumnsEqualWidth = makeColumnsEqualWidth; + layout.numColumns = numColumns; + return layout; + } + +} \ No newline at end of file diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignFormSectionFactory.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignFormSectionFactory.java new file mode 100644 index 00000000..2d8e7fb6 --- /dev/null +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignFormSectionFactory.java @@ -0,0 +1,210 @@ +/* + * $Id: View.java 860 2008-10-17 07:43:35Z cleduc $ + * + * Copyright (C) INRIA, 2007-2008 + * + * 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 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.plugin.neontk; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.forms.widgets.ExpandableComposite; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.forms.widgets.TableWrapData; +import fr.inrialpes.exmo.align.plugin.neontk.AlignFormLayoutFactory; + +public class AlignFormSectionFactory { + + private static Section gridExpandableSection; + private static Section simpleSection; + + public static Composite createStaticSection( final FormToolkit toolkit, + final Composite parent, + final String sectionTitle, + final String sectionDescription, + final int numOfColumns ) { + Section section; + section = toolkit.createSection( parent, + ExpandableComposite.TITLE_BAR | + Section.DESCRIPTION | + SWT.WRAP ); + section.setText( sectionTitle ); + section.setDescription( sectionDescription ); + toolkit.createCompositeSeparator( section ); + section.setLayout( AlignFormLayoutFactory.createClearTableWrapLayout( false, 1 ) ); + TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB ); + section.setLayoutData( data ); + Composite client = toolkit.createComposite( section ); + client.setLayout( AlignFormLayoutFactory.createSectionClientTableWrapLayout( false, numOfColumns ) ); + section.setClient( client ); + return client; + } + + public static Composite createHtmlSection( final FormToolkit toolkit, + final Composite parent, + final String sectionTitle) { + Section section; + + section = toolkit.createSection( parent, + ExpandableComposite.TITLE_BAR | + Section.DESCRIPTION | + ExpandableComposite.TWISTIE | + SWT.WRAP ); + section.setText(sectionTitle); + + Composite client = toolkit.createComposite( section ); + + section.setClient( client ); + return client; + + } + public static Composite createExpandableSection( final FormToolkit toolkit, + final Composite parent, + final String sectionTitle, + final String sectionDescription, + final int numOfColumns, + final boolean isInitialyExpanded ) { + Section section; + if ( isInitialyExpanded ) { + section = toolkit.createSection( parent, + ExpandableComposite.TITLE_BAR | + Section.DESCRIPTION | + ExpandableComposite.TWISTIE | + SWT.WRAP ); + } else { + section = toolkit.createSection( parent, + ExpandableComposite.TITLE_BAR | + Section.DESCRIPTION | + ExpandableComposite.TWISTIE ); + } + section.setText( sectionTitle ); + section.setDescription( sectionDescription ); + toolkit.createCompositeSeparator( section ); + section.setLayout( AlignFormLayoutFactory.createClearTableWrapLayout( false, 1 ) ); + TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB ); + section.setLayoutData( data ); + Composite client = toolkit.createComposite( section ); + client.setLayout( AlignFormLayoutFactory.createSectionClientTableWrapLayout( false, numOfColumns ) ); + section.setClient( client ); + return client; + } + + public static Composite createGridStaticSection( final FormToolkit toolkit, + final Composite parent, + final String sectionTitle, + final String sectionDescription, + final int numOfColumns ) { + + Section section; + if (sectionDescription.length() > 0) { + section = toolkit.createSection(parent, + ExpandableComposite.TITLE_BAR | Section.DESCRIPTION + | SWT.WRAP); + section.setText(sectionTitle); + section.setDescription(sectionDescription); + } else { + section = toolkit.createSection(parent, + ExpandableComposite.TITLE_BAR | SWT.WRAP); + section.setText(sectionTitle); + } + + toolkit.createCompositeSeparator( section ); + section.setLayout( AlignFormLayoutFactory.createClearTableWrapLayout( false, 1 ) ); + TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB ); + section.setLayoutData( data ); + + Composite client = toolkit.createComposite( section ); + client.setLayout( AlignFormLayoutFactory.createSectionClientGridLayout( false, numOfColumns ) ); + section.setClient( client ); + return client; + } + + public static Composite createGridExpandableSection( final FormToolkit toolkit, + final Composite parent, + final String sectionTitle, + final String sectionDescription, + final int numOfColumns, + final boolean isInitialyExpanded ) { + + Section section; + if ( isInitialyExpanded ) { + section = toolkit.createSection( parent, + ExpandableComposite.TITLE_BAR | + Section.DESCRIPTION | + ExpandableComposite.TWISTIE | + SWT.WRAP ); + } else { + section = toolkit.createSection( parent, + ExpandableComposite.TITLE_BAR | + Section.DESCRIPTION | + ExpandableComposite.TWISTIE ); + } + section.setText( sectionTitle ); + section.setDescription( sectionDescription ); + toolkit.createCompositeSeparator( section ); + section.setLayout( AlignFormLayoutFactory.createClearTableWrapLayout( false, 1 ) ); + TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB ); + section.setLayoutData( data ); + gridExpandableSection = section; + Composite client = toolkit.createComposite( section ); + client.setLayout( AlignFormLayoutFactory.createSectionClientGridLayout( false, numOfColumns ) ); + section.setClient( client ); + return client; + } + + + public static Composite createGridExpandableSection( + final FormToolkit toolkit, final Composite parent, + final String sectionTitle, final int numOfColumns, + final boolean isInitialyExpanded) { + + Section section; + if (isInitialyExpanded) { + section = toolkit.createSection(parent, + ExpandableComposite.TITLE_BAR + | ExpandableComposite.TWISTIE | SWT.WRAP); + } else { + section = toolkit.createSection(parent, + ExpandableComposite.TITLE_BAR + | ExpandableComposite.TWISTIE); + } + section.setText(sectionTitle); + toolkit.createCompositeSeparator(section); + section.setLayout(AlignFormLayoutFactory + .createClearTableWrapLayout(false, 1)); + TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB); + section.setLayoutData(data); + gridExpandableSection = section; + Composite client = toolkit.createComposite(section); + client.setLayout(AlignFormLayoutFactory.createSectionClientGridLayout(false, + numOfColumns)); + section.setClient(client); + return client; + } + + public static Section getGridExpendableSection() { + return gridExpandableSection; + } + + public static Section getSimpleSection() { + return simpleSection; + } + + +} diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignView.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignView.java index a88a6a2e..ba597b00 100755 --- a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignView.java +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignView.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) INRIA Rh�ne-Alpes, 2007-2008 + * Copyright (C) INRIA, 2007-2008 * * 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 @@ -21,29 +21,846 @@ package fr.inrialpes.exmo.align.plugin.neontk; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.swt.awt.SWT_AWT; -import java.awt.BorderLayout; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.io.File; +import java.net.URI; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JEditorPane; +import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; -import java.awt.Frame; + + +import org.eclipse.ui.part.ViewPart; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.forms.widgets.ScrolledFormText; +import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.forms.widgets.TableWrapData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.dialogs.MessageDialog; + +//import org.eclipse.jface.dialogs.MessageDialog; +import org.semanticweb.kaon2.api.OntologyManager; +import org.semanticweb.owl.align.Alignment; + +import com.ontoprise.ontostudio.datamodel.DatamodelPlugin; + +import fr.inrialpes.exmo.align.onto.owlapi10.OWLAPIOntologyFactory; +import fr.inrialpes.exmo.align.plugin.neontk.AlignFormLayoutFactory; +import fr.inrialpes.exmo.align.plugin.neontk.AlignFormSectionFactory; +import fr.inrialpes.exmo.align.plugin.neontk.OnlineAlign; +import fr.inrialpes.exmo.align.plugin.neontk.WSDialog; +import fr.inrialpes.exmo.align.plugin.neontk.OnlineDialog; +//import org.eclipse.swt.awt.SWT_AWT; +//import java.awt.BorderLayout; +//import javax.swing.JPanel; +//import java.awt.Frame; +//import org.eclipse.albireo.core.SwingControl; -public class AlignView extends ViewPart { +public class AlignView extends ViewPart + implements SelectionListener, Listener { + + public static final String ID = "fr.inrialpes.exmo.align.plugin.neontk.alignView"; + private Combo methods, renderer, localAlignBox, ontoBox1, ontoBox2, serverAlignBox; + private Button cancelButton, discardButton, resButton, onto1Refresh, onto2Refresh, + localImportButton, serverImportButton, uploadButton, + localTrimButton, serverTrimButton, connButton, goButton, offlineButton, onlineButton; + private Button storeButton, matchButton, findButton, findAllButton, fetchButton; + //private String selectedProject = null; + //private Section ontoSelectSection; + //private Section alignViewSection; + + private String selectedOnto1, selectedOnto2, selectedLocalAlign, selectedServerAlign; + private String[] ontoList = new String[0]; + private String[] methodList = new String[0]; + public HashMap<String,String> ontoByProj = new HashMap<String,String>(0); + //String selectedLocalAlign = null; + //String selectedAlign = null; + + public static Hashtable<String,Alignment> alignmentTable = new Hashtable<String,Alignment>(); + static String [] forUniqueness = new String[0]; + static int alignId = 0; + + Composite composite = null; + int width = 700; + int buttonWidth = 150; + int buttonHeight = 30; + + boolean online = false; - public static final String ID = "fr.inrialpes.exmo.align.plugin.neontk.alignView"; - - public void setFocus() { - } - - public void createPartControl(Composite parent) { - final Composite composite = new Composite(parent, SWT.EMBEDDED); - final Frame f = SWT_AWT.new_Frame(composite); - - JPanel panel = new JPanel(new BorderLayout()); - f.add(panel); - SWTInterface lo= new SWTInterface(); - lo.run(); - f.add(lo); - } + String selectedHost = "aserv.inrialpes.fr"; + String selectedPort = "80"; + + String selectedMethod = "fr.inrialpes.exmo.align.impl.method.NameEqAlignment"; + String wserver = "http://kameleon.ijs.si/ontolight/ontolight.asmx"; + String wsmethod=""; + + + String alignProject = "AlignmentProject"; + + public OnlineAlign onlineAlign = null; + public OfflineAlign offlineAlign = null; + public File ontoFolder = null; + public File alignFolder = null; + public static File basicFolder = null; + + @Override + public void createPartControl(final Composite parent) { + FormToolkit formToolkit = new FormToolkit(Display.getCurrent()); + ScrolledForm scrolledForm = formToolkit.createScrolledForm(parent); + Composite body = scrolledForm.getBody(); + body.setLayout(AlignFormLayoutFactory.createFormTableWrapLayout(false,1)); + composite = formToolkit.createComposite(body); + composite.setLayout(AlignFormLayoutFactory.createFormPaneTableWrapLayout(false, 1)); + composite.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); + + createOntologyChoosePart(composite, formToolkit); + createAlignmentPart(composite, formToolkit); + //createOntologyInfoSection(composite, formToolkit); + //createMUPSSection(composite, formToolkit); + //createInconsistencyResultSection(composite, formToolkit); + //this.refreshProjectList(); + IWorkspaceRoot root = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot(); + IPath location = root.getLocation(); + String path = location.toOSString(); + + + //ontoFolder = new File(path + location.SEPARATOR + "onto"); + ontoFolder = new File(path + location.SEPARATOR + "align"); + + if (!ontoFolder.exists()) ontoFolder.mkdir(); + basicFolder = new File(path + location.SEPARATOR ); + alignFolder = new File(path + location.SEPARATOR + "align"); + if (!alignFolder.exists()) alignFolder.mkdir(); + + offlineInit( true ); + + refreshOntoList( true ); + } + + private void createOntologyChoosePart(final Composite parent, + final FormToolkit toolkit){ + + String sectionTitle = "Input"; + Composite client ; + int columns = 6; + int textWidth = 600; + int textHeight = 20; + GridData gd = new GridData(); + gd.widthHint = textWidth; + gd.heightHint = textHeight; + + client = AlignFormSectionFactory.createGridExpandableSection( + toolkit, parent, sectionTitle, columns, true); + Section ontoSelectSection = AlignFormSectionFactory.getGridExpendableSection(); + ontoSelectSection.setExpanded(true); + + onlineButton = new Button(client, SWT.PUSH); + onlineButton.setText("Online"); + onlineButton.setSize(buttonWidth, buttonHeight); + onlineButton.addSelectionListener(this); + onlineButton.setEnabled( true ); + + offlineButton = new Button(client, SWT.PUSH); + offlineButton.setText("Offline"); + offlineButton.setSize(buttonWidth, buttonHeight); + offlineButton.addSelectionListener(this); + offlineButton.setEnabled( false ); + + Label dummy1 = new Label(client, SWT.NONE); + Label dummy2 = new Label(client, SWT.NONE); + Label dummy3 = new Label(client, SWT.NONE); + Label dummy4 = new Label(client, SWT.NONE); + + // Choose ontology 1 + Label onto1 = new Label(client, SWT.NONE); + onto1.setText("Ontology 1 "); + ontoBox1 = new Combo(client, SWT.DROP_DOWN | SWT.READ_ONLY ); + ontoBox1.setLayoutData( gd ); + ontoBox1.setEnabled(true); + ontoBox1.addSelectionListener(this); + onto1Refresh = new Button(client, SWT.PUSH); + onto1Refresh.setText("Refresh"); + onto1Refresh.setSize(buttonWidth, buttonHeight); + onto1Refresh.addSelectionListener(this); + onto1Refresh.setEnabled(true); + Label dummy5 = new Label(client, SWT.NONE); + Label dummy6 = new Label(client, SWT.NONE); + Label dummy7 = new Label(client, SWT.NONE); + + //Choose ontology 2 + Label onto2 = new Label(client, SWT.NONE); + onto2.setText("Ontology 2 "); + ontoBox2 = new Combo(client, SWT.DROP_DOWN | SWT.READ_ONLY ); + ontoBox2.setLayoutData(gd); + ontoBox2.setEnabled(true); + ontoBox2.addSelectionListener(this); + onto2Refresh = new Button(client, SWT.PUSH); + onto2Refresh.setText("Refresh"); + onto2Refresh.setSize(buttonWidth, buttonHeight); + onto2Refresh.addSelectionListener(this); + onto2Refresh.setEnabled(true); + Label dummy8 = new Label(client, SWT.NONE); + Label dummy9 = new Label(client, SWT.NONE); + Label dummy10 = new Label(client, SWT.NONE); + + //methods + Label methodLabel = new Label(client, SWT.NONE); + methodLabel.setText("Methods "); + methods = new Combo(client, SWT.DROP_DOWN | SWT.READ_ONLY ); + methods.setLayoutData(gd); + methods.setEnabled(true); + methods.addSelectionListener(this); + + //match + matchButton = new Button(client, SWT.PUSH); + matchButton.setText("Match"); + matchButton.setSize(buttonWidth, buttonHeight); + matchButton.addSelectionListener(this); + matchButton.setEnabled(true); + + Label dummy11 = new Label(client, SWT.NONE); + Label dummy12 = new Label(client, SWT.NONE); + Label dummy13 = new Label(client, SWT.NONE); + + //server alignment list + Label serverAlignLabel = new Label(client, SWT.NONE ); + serverAlignLabel.setText("Server alignments"); + + serverAlignBox = new Combo(client, SWT.DROP_DOWN | SWT.READ_ONLY ); + serverAlignBox.setLayoutData(gd); + serverAlignBox.setEnabled( false ); + serverAlignBox.addSelectionListener(this); + + + //import + serverImportButton = new Button(client, SWT.PUSH); + serverImportButton.setText("Import"); + serverImportButton.setSize(buttonWidth, buttonHeight); + serverImportButton.addSelectionListener(this); + serverImportButton.setEnabled(false); + + //trim + serverTrimButton = new Button(client, SWT.PUSH); + serverTrimButton.setText("Trim"); + serverTrimButton.setSize(buttonWidth, buttonHeight); + serverTrimButton.addSelectionListener(this); + serverTrimButton.setEnabled(false); + + //store + storeButton = new Button(client, SWT.PUSH); + storeButton.setText("Store"); + storeButton.setSize(buttonWidth, buttonHeight); + storeButton.addSelectionListener(this); + storeButton.setEnabled(false); + + //fetch + fetchButton = new Button(client, SWT.PUSH); + fetchButton.setText("Fetch"); + fetchButton.setSize(buttonWidth, buttonHeight); + fetchButton.addSelectionListener(this); + fetchButton.setEnabled(false); + + //local alignment list + Label localAlignLabel = new Label(client, SWT.NONE ); + localAlignLabel.setText("Local alignments"); + + localAlignBox = new Combo(client, SWT.DROP_DOWN | SWT.READ_ONLY ); + localAlignBox.setLayoutData(gd); + localAlignBox.setEnabled(false); + localAlignBox.addSelectionListener(this); + + //local import + localImportButton = new Button(client, SWT.PUSH); + localImportButton.setText("Import"); + localImportButton.setSize(buttonWidth, buttonHeight); + localImportButton.addSelectionListener(this); + localImportButton.setEnabled(false); + + //local trim + localTrimButton = new Button(client, SWT.PUSH); + localTrimButton.setText("Trim"); + localTrimButton.setSize(buttonWidth, buttonHeight); + localTrimButton.addSelectionListener(this); + localTrimButton.setEnabled(false); + + //upload + uploadButton = new Button(client, SWT.PUSH); + uploadButton.setText("Upload"); + uploadButton.setSize(buttonWidth, buttonHeight); + uploadButton.addSelectionListener(this); + uploadButton.setEnabled(false); + + Label dummy14 = new Label(client, SWT.NONE); + + Label dummy15 = new Label(client, SWT.NONE); + Label dummy16 = new Label(client, SWT.NONE); + Label dummy17 = new Label(client, SWT.NONE); + Label dummy18 = new Label(client, SWT.NONE); + Label dummy19 = new Label(client, SWT.NONE); + Label dummy20 = new Label(client, SWT.NONE); + + Label dummy21 = new Label(client, SWT.NONE); + + //find + findButton = new Button(client, SWT.PUSH); + findButton.setText("Find alignments for ontologies"); + findButton.setSize(buttonWidth, buttonHeight); + findButton.addSelectionListener(this); + findButton.setEnabled(false); + + Label dummy22 = new Label(client, SWT.NONE); + Label dummy23 = new Label(client, SWT.NONE); + Label dummy24 = new Label(client, SWT.NONE); + Label dummy25 = new Label(client, SWT.NONE); + Label dummy26 = new Label(client, SWT.NONE); + + //find all + findAllButton = new Button(client, SWT.PUSH); + findAllButton.setText("Find all alignments from server"); + findAllButton.setSize(buttonWidth, buttonHeight); + findAllButton.addSelectionListener(this); + findAllButton.setEnabled(false); + + toolkit.paintBordersFor(client); + } + + private void createAlignmentPart(final Composite parent, + final FormToolkit toolkit){ + + String sectionTitle = "View Alignment"; + //int columns = 1; + //int textWidth = 800; + //int textHeight = 20; + //FillLayout fl = new FillLayout(); + //Composite client = new ScrolledFormText( parent, true ); + //fl.widthHint = textWidth; + //fl.heightHint = textHeight; + //String tx = "<html><body>This is Unicode HTML content from memory</body></html>"; + Composite client = AlignFormSectionFactory.createHtmlSection( + toolkit, parent, sectionTitle); + //client = AlignFormSectionFactory.createGridExpandableSection( + //toolkit, parent, sectionTitle, columns, true); + //alignViewSection = AlignFormSectionFactory.getGridExpendableSection(); + //alignViewSection = AlignFormSectionFactory.getSimpleSection(); + //alignViewSection.setExpanded( true ); + + //Composite client = new ScrolledFormText( parent, true ); + + client.setLayout(new FillLayout()); + client.setSize(960, 720); + client.setLocation(0, 0); + + Browser browser = new Browser(client, SWT.BORDER); + browser.setText("<html><body>This is Unicode HTML content from memory</body></html>"); + + toolkit.paintBordersFor(client); + } + + public void handleEvent(Event e) { + + } + + public void widgetSelected(SelectionEvent e) { + if ( e.getSource().equals( this.onlineButton ) ) { + //this.onlineButton.setExpanded(true); + OnlineDialog onDialog = new OnlineDialog( getSite().getShell() ); + onDialog.setInput("aserv.inrialpes.fr"); + onDialog.open(); + if ( !(onDialog.getInput() == null) && !onDialog.getInput().equals("")) { + online = true; + selectedHost = onDialog.getInput(); + onlineAlign = new OnlineAlign(selectedPort, selectedHost ); + + String list[] = onlineAlign.getMethods(); + if(list == null || list.length ==0) { + MessageDialog.openError(this.getSite().getShell(), "Error message", + "Impossible connection!"); + return; + } + if(localAlignBox.getItems()==null || localAlignBox.getItems().length ==0) { + setButtons( 3 ); //no localList, no server list + + } else { + setButtons( 6 ); //with localList, no server list + } + selectedOnto1 = null; + selectedOnto2 = null; + selectedServerAlign = null; + selectedLocalAlign = null; + methods.removeAll(); + selectedMethod = list[0]; + methods.setItems( list ); + methods.select(0); + methods.redraw(); + } + + } else if ( e.getSource().equals( this.offlineButton ) ) { + offlineInit( false ); + + } else if (e.getSource() == onto1Refresh) { + ontoByProj = this.refreshOntoList( online ); + + } else if (e.getSource() == onto2Refresh) { + ontoByProj = this.refreshOntoList( online ); + } else if (e.getSource() == matchButton) { + + if (selectedOnto1 == null || selectedOnto2 == null ) { + MessageDialog.openError(this.getSite().getShell(), "Error message", + "Choose two ontologies from lists! "); + return; + } + + if( online ) { + if (!selectedOnto1.startsWith("http://") || !selectedOnto2.startsWith("http://") ) { + MessageDialog.openError(this.getSite().getShell(), "Error message", "URLs for ontologies are required."); + return; + } + if( selectedMethod.equals("fr.inrialpes.exmo.align.service.WSAlignment")) { + + WSDialog pa = new WSDialog( getSite().getShell() ); + if( pa.getServerInput() == null || pa.getServerInput().equals("")) { + MessageDialog.openError(this.getSite().getShell(), "Error message", "No server!"); + return; + } else { + wserver = pa.getServerInput(); + wsmethod = pa.getMethodInput(); + String alignId = onlineAlign.getAlignIdMonoThread( selectedMethod, wserver, wsmethod, selectedOnto1, selectedOnto2 ); + String[] list = new String[1]; + list[0] = alignId; + selectedServerAlign = alignId; + serverAlignBox.removeAll(); + serverAlignBox.setItems(list); + serverAlignBox.select(0); + serverAlignBox.redraw(); + } + + } else { + //resetActionButtons( false ); + String alignId = onlineAlign.getAlignIdMonoThread( selectedMethod, wserver, wsmethod, selectedOnto1, selectedOnto2 ); + //onAlign.getAlignId( matchMethod, wserver, wsmethod, selectedOnto1, selectedOnto2 ); + String[] list = new String[1]; + list[0] = alignId; + selectedServerAlign = list[0]; + serverAlignBox.removeAll(); + serverAlignBox.select(0); + serverAlignBox.redraw(); + + } + + //String answer = onAlign.getAlignId( matchMethod, selectedOnto1, selectedOnto2 ); + //if(answer==null || answer.equals("")) { + // JOptionPane.showMessageDialog(null, "Alignment is not produced.","Warning",2); + // return; + //} + //alignIdList = new String[1]; + //alignIdList[0] = answer; + //selectedAlign = alignIdList[0]; + //alignBox.removeAllItems(); + //alignBox.addItem(selectedAlign); + //onAlign.getRDFAlignment( selectedAlign, alignImportButton, alignStoreButton, + // serverAlignTrimButton, allAlignButton, alignFindButton, mapButton); + + } + else { //offline + + String resId = offlineAlign.matchAndExportAlign( selectedMethod, ontoByProj.get(selectedOnto1), selectedOnto1, ontoByProj.get(selectedOnto2), selectedOnto2); + + localAlignBox.removeAll(); + String[] list = new String[1]; + + //File f1 = new File(resId); + list[0] = resId;//"file:" + f1.getAbsolutePath(); + + localAlignBox.setItems(list); + selectedLocalAlign = list[0]; + localAlignBox.select(0); + localAlignBox.redraw(); + + } //offline + } else if (e.getSource() == localImportButton) {//matchButton + + } else if ( e.getSource().equals( this.findAllButton ) ) { + + String[] onList = null; + String[] offList = null; + + if(online) { + onList = onlineAlign.getAllAlign(); + if(onList == null || onList.length==0) { + MessageDialog.openError(this.getSite().getShell(), "Error message", "No available alignment"); + return; + } + //serverAlignBox.setEnabled( true ); + serverAlignBox.removeAll(); + serverAlignBox.setItems(onList); + selectedServerAlign = onList[0]; + serverAlignBox.select(0); + serverAlignBox.redraw(); + + offList = offlineAlign.getAllAlign( ); + if( offList != null && offList.length > 0 ) { + //localAlignBox.setEnabled( true ); + localAlignBox.removeAll(); + localAlignBox.setItems( offList ); + selectedLocalAlign = offList[0]; + localAlignBox.select(0); + localAlignBox.redraw(); + } + } + + if( onList.length > 0 && (offList.length > 0) ) { + setButtons( 7 ); + } + else if( onList.length == 0 && offList.length > 0 ) + setButtons( 6 ); + else if( onList.length == 0 && offList.length == 0 ) + setButtons( 3 ); + else if( onList.length >0 && offList.length == 0 ) { + //System.out.println("OK "); + setButtons( 8 ); + } + } else if ( e.getSource().equals( this.findButton ) ) { + String[] onList = null; + if(online) { + if(selectedOnto1 == null || selectedOnto1.equals("") || selectedOnto2 == null || selectedOnto2.equals("")) { + MessageDialog.openError(this.getSite().getShell(), "Error message", "Please choose ontologies."); + return; + } + onList = onlineAlign.findAlignForOntos( selectedOnto1, selectedOnto2); + if(onList == null || onList.length==0) { + MessageDialog.openError(this.getSite().getShell(), "Error message", "No available alignment."); + return; + } + serverAlignBox.setEnabled( true ); + serverAlignBox.removeAll(); + serverAlignBox.setItems(onList); + selectedServerAlign = onList[0]; + serverAlignBox.select(0); + serverAlignBox.redraw(); + } + } + } + + + void offlineInit(boolean init) { + online = false; + methods.removeAll(); + serverAlignBox.removeAll(); + localAlignBox.removeAll(); + ontoBox1.removeAll(); + ontoBox2.removeAll(); + + String[] methodList = new String[8]; + methodList[0] = "fr.inrialpes.exmo.align.impl.method.NameEqAlignment"; + + methodList[1] = "fr.inrialpes.exmo.align.impl.method.StringDistAlignment"; + + methodList[2] = "fr.inrialpes.exmo.align.impl.method.SMOANameAlignment"; + + methodList[3] = "fr.inrialpes.exmo.align.impl.method.SubsDistNameAlignment"; + + methodList[4] = "fr.inrialpes.exmo.align.impl.method.StrucSubsDistAlignment"; + + methodList[5] = "fr.inrialpes.exmo.align.impl.method.NameAndPropertyAlignment"; + + methodList[6] = "fr.inrialpes.exmo.align.impl.method.ClassStructAlignment"; + + methodList[7] = "fr.inrialpes.exmo.align.impl.method.EditDistNameAlignment"; + + selectedMethod = methodList[0]; + methods.removeAll(); + methods.setItems( methodList ); + methods.select(0); + methods.redraw(); + + System.out.println( "alignFolder=" + alignFolder ); + + offlineAlign = new OfflineAlign( alignFolder, ontoFolder ); + + //initButtons( false ); + + if( init ) + offlineAlign.getAllAlignFromFiles(); + + String[] list = offlineAlign.getAllAlign(); + localAlignBox.removeAll(); + + if(list != null && list.length > 0) { + forUniqueness = new String[list.length]; + + for(int i=0; i< list.length; i++){ + System.out.println( "filename=" + list[i] ); + File f = new File(list[i]); + forUniqueness[i] = f.getName(); + } + localAlignBox.setItems( list ); + selectedLocalAlign = list[0]; + setButtons( 1 ); + + } else { + setButtons( 0 ); + } + } + + void setButtons( int status ) { + switch (status) { + case 0 : // activate offline no localList + onlineButton.setEnabled( true ); + offlineButton.setEnabled( false ); + findButton.setEnabled(false); + findAllButton.setEnabled(false); + + serverAlignBox.setEnabled( false ); + serverImportButton.setEnabled( false ); + serverTrimButton.setEnabled( false ); + storeButton.setEnabled( false ); + fetchButton.setEnabled( false ); + uploadButton.setEnabled( false ); + + localAlignBox.setEnabled( false ); + localImportButton.setEnabled( false ); + localTrimButton.setEnabled( false ); + break; + + case 1 : // activate offline with localList + onlineButton.setEnabled( true ); + offlineButton.setEnabled( false ); + findButton.setEnabled(false); + findAllButton.setEnabled(false); + + serverAlignBox.setEnabled( false ); + serverImportButton.setEnabled( false ); + serverTrimButton.setEnabled( false ); + storeButton.setEnabled( false ); + fetchButton.setEnabled( false ); + uploadButton.setEnabled( false ); + + localAlignBox.setEnabled( true ); + localImportButton.setEnabled( true ); + localTrimButton.setEnabled( true ); + break; + + case 2 : // activate online no list + onlineButton.setEnabled( false ); + offlineButton.setEnabled( true ); + findButton.setEnabled(true); + findAllButton.setEnabled(true); + + serverAlignBox.setEnabled( false ); + serverImportButton.setEnabled( false ); + serverTrimButton.setEnabled( false ); + storeButton.setEnabled( false ); + fetchButton.setEnabled( false ); + uploadButton.setEnabled( false ); + + + localAlignBox.setEnabled( false ); + localImportButton.setEnabled( false ); + localTrimButton.setEnabled( false ); + break; + + case 3 : // activate online no localList (no server List) + onlineButton.setEnabled( false ); + offlineButton.setEnabled( true ); + findButton.setEnabled(true); + findAllButton.setEnabled(true); + + serverAlignBox.setEnabled( false ); + serverImportButton.setEnabled( false ); + serverTrimButton.setEnabled( false ); + storeButton.setEnabled( false ); + fetchButton.setEnabled( false ); + uploadButton.setEnabled( false ); + + + localAlignBox.setEnabled( false ); + localImportButton.setEnabled( false ); + localTrimButton.setEnabled( false ); + break; + + case 4 : // activate online align. not available + onlineButton.setEnabled( false ); + offlineButton.setEnabled( true ); + findButton.setEnabled(true); + findAllButton.setEnabled(true); + + serverAlignBox.setEnabled( true ); + serverImportButton.setEnabled( true ); + serverTrimButton.setEnabled( false ); + storeButton.setEnabled( false ); + fetchButton.setEnabled( true ); + uploadButton.setEnabled( true ); + + + localAlignBox.setEnabled( true ); + localImportButton.setEnabled( true ); + localTrimButton.setEnabled( true ); + break; + + case 5 : // activate online align available + onlineButton.setEnabled( false ); + offlineButton.setEnabled( true ); + findButton.setEnabled(true); + findAllButton.setEnabled(true); + + serverAlignBox.setEnabled( true ); + serverImportButton.setEnabled( true ); + serverTrimButton.setEnabled( true ); + storeButton.setEnabled( true ); + fetchButton.setEnabled( true ); + uploadButton.setEnabled( true ); + + + localAlignBox.setEnabled( true ); + localImportButton.setEnabled( true ); + localTrimButton.setEnabled( true ); + break; + + case 6 : // activate online with localList (no serverList) + onlineButton.setEnabled( false ); + offlineButton.setEnabled( true ); + findButton.setEnabled( true ); + findAllButton.setEnabled( true ); + + serverAlignBox.setEnabled( false ); + serverImportButton.setEnabled( false ); + serverTrimButton.setEnabled( false ); + storeButton.setEnabled( false ); + fetchButton.setEnabled( false ); + uploadButton.setEnabled( true ); + + localAlignBox.setEnabled( true ); + localImportButton.setEnabled( true ); + localTrimButton.setEnabled( true ); + break; + + case 7 : // activate online with both Lists + onlineButton.setEnabled( false ); + offlineButton.setEnabled( true ); + findButton.setEnabled( true ); + findAllButton.setEnabled( true ); + + serverAlignBox.setEnabled( true ); + serverImportButton.setEnabled( false ); + serverTrimButton.setEnabled( false ); + storeButton.setEnabled( false ); + fetchButton.setEnabled( true ); + uploadButton.setEnabled( true ); + + localAlignBox.setEnabled( true ); + localImportButton.setEnabled( true ); + localTrimButton.setEnabled( true ); + break; + + case 8 : // activate online with server list but no local list + onlineButton.setEnabled( false ); + offlineButton.setEnabled( true ); + findButton.setEnabled( true ); + findAllButton.setEnabled( true ); + + serverAlignBox.setEnabled( true ); + serverImportButton.setEnabled( false ); + serverTrimButton.setEnabled( false ); + storeButton.setEnabled( false ); + fetchButton.setEnabled( true ); + uploadButton.setEnabled( true ); + + localAlignBox.setEnabled( false ); + localImportButton.setEnabled( false ); + localTrimButton.setEnabled( false ); + break; + default: + break; + } + } + + + private HashMap<String,String> refreshOntoList(boolean online) { + HashMap<String,String> vec = new HashMap<String,String>(); + OWLAPIOntologyFactory fact = new OWLAPIOntologyFactory(); + try { + String[] projects = DatamodelPlugin.getDefault().getOntologyProjects(); + if(projects != null) { + for(int i=0; i < projects.length; i++) { + if(projects[i]!=null) { + + OntologyManager connection = DatamodelPlugin.getDefault().getKaon2Connection(projects[i]); + Set<String> strSet = connection.getAvailableOntologyURIs(); + String[] uris = (String[])strSet.toArray(new String[0]); + if(online) { + for(int k=0; k < uris.length; k++) { + //get only http URL + if(uris[k].startsWith("http://")) + try { + fact.loadOntology(new URI(uris[k])); + vec.put(uris[k],projects[i]); + } catch (Exception ex) { + } + } + } else { + for(int k=0; k < uris.length; k++) { + vec.put(DatamodelPlugin.getDefault().getPhysicalOntologyUri(projects[i], uris[k]).toString(),projects[i]); + } + } + } + } + } + else { + //System.out.printf("No Ontology Project !" ); + return null; + } + } catch ( Exception ex ) { ex.printStackTrace();}; + + ontoBox1.removeAll(); + ontoBox2.removeAll(); + + String[] keys = (String[]) vec.keySet().toArray(new String[0]); + + if(keys.length>0){ + ontoList = new String[ keys.length ]; + ontoBox1.setItems(keys); + ontoBox1.select(0); + ontoBox1.redraw(); + selectedOnto1 = keys[0]; + ontoBox2.setItems(keys); + ontoBox2.select(0); + ontoBox2.redraw(); + selectedOnto2 = keys[0]; + } + + return vec; + } + @Override + public void setFocus() { + // TODO Auto-generated method stub + + } + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } } diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignmentPlugin.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignmentPlugin.java index 7d6691c1..8a0c8cea 100755 --- a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignmentPlugin.java +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/AlignmentPlugin.java @@ -21,7 +21,7 @@ package fr.inrialpes.exmo.align.plugin.neontk; -import org.eclipse.ui.plugin.*; +import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; import org.osgi.framework.BundleContext; diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/OnlineAlign.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/OnlineAlign.java index 8376e985..33acc433 100755 --- a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/OnlineAlign.java +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/OnlineAlign.java @@ -35,11 +35,10 @@ import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.PrintWriter; import java.io.StringWriter; +import java.lang.StringBuffer; //mport javax.swing.JOptionPane; import javax.swing.ProgressMonitorInputStream; -//import javax.swing.JComponent; -//import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.ProgressMonitor; @@ -313,6 +312,7 @@ public class OnlineAlign { // Send message answer = sendMessage( message, params ); + //System.out.println("Answer get All :"+ answer); } catch ( Exception ex ) { ex.printStackTrace(); }; @@ -1244,11 +1244,12 @@ public class OnlineAlign { BufferedReader in = new BufferedReader(isr); String line; + StringBuffer strBuff = new StringBuffer(); while ((line = in.readLine()) != null) { - answer += line + "\n"; + strBuff.append( line + "\n"); } if (in != null) in.close(); - + answer = strBuff.toString(); } catch (Exception ex) { connected= false; ex.printStackTrace() ; return null; diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/OnlineDialog.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/OnlineDialog.java new file mode 100644 index 00000000..56559359 --- /dev/null +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/OnlineDialog.java @@ -0,0 +1,140 @@ +/* + * $Id: View.java 860 2008-10-17 07:43:35Z cleduc $ + * + * Copyright (C) INRIA, 2007-2008 + * + * 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 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.plugin.neontk; + + +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Dialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridLayout; + +import org.eclipse.swt.SWT; + +public class OnlineDialog extends Dialog { + private String message; + private String input; + + public OnlineDialog(Shell parent) { + // Pass the default styles here + this(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL ); + } + + + public OnlineDialog(Shell parent, int style) { + // Let users override the default styles + super(parent, style); + setText("Alignment Server"); + setMessage("Please enter server URL:"); + } + + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + + public String getInput() { + return input; + } + + + public void setInput(String input) { + this.input = input; + } + + public String open() { + // Create the dialog window + Shell shell = new Shell(getParent(), getStyle()); + shell.setText(getText()); + createContents(shell); + shell.pack(); + shell.open(); + Display display = getParent().getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + // Return the entered value, or null + return input; + } + + + private void createContents(final Shell shell) { + shell.setLayout(new GridLayout(2, true)); + + // Show the message + Label label = new Label(shell, SWT.NONE); + label.setText(message); + GridData data = new GridData(); + data.horizontalSpan = 6; + label.setLayoutData(data); + + // Display the input box + final Text text = new Text(shell, SWT.BORDER); + text.setText("aserv.inrialpes.fr"); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 2; + text.setLayoutData(data); + + // Create the OK button and add a handler + // so that pressing it will set input + // to the entered value + Button ok = new Button(shell, SWT.PUSH); + ok.setText("OK"); + data = new GridData(GridData.FILL_HORIZONTAL); + ok.setLayoutData(data); + ok.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + input = text.getText(); + shell.close(); + } + }); + + // Create the cancel button and add a handler + // so that pressing it will set input to null + Button cancel = new Button(shell, SWT.PUSH); + cancel.setText("Cancel"); + data = new GridData(GridData.FILL_HORIZONTAL); + cancel.setLayoutData(data); + cancel.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + input = null; + shell.close(); + } + }); + + // Set the OK button as the default, so + // user can type input and press Enter + // to dismiss + shell.setDefaultButton(ok); + } + } diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/SWTInterface.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/SWTInterface.java index 98ec1491..fe57d131 100644 --- a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/SWTInterface.java +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/SWTInterface.java @@ -590,7 +590,7 @@ public class SWTInterface extends JPanel { } }); - localAlignImportButton = new JButton("Export",null); + localAlignImportButton = new JButton("Import",null); localAlignImportButton.setEnabled(false); localAlignImportButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { @@ -716,7 +716,7 @@ public class SWTInterface extends JPanel { }; }); - alignImportButton = new JButton("Export",null); + alignImportButton = new JButton("Import",null); alignImportButton.setEnabled(false); alignImportButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { @@ -763,7 +763,7 @@ public class SWTInterface extends JPanel { File file = new File(rdfPath); AlignmentParser ap = new AlignmentParser(0); - ap.setEmbedded(true); + ap.setEmbedded( true ); align = (URIAlignment)ap.parse(file.toURI().toString()); SWTInterface.alignmentTable.put( alignKey , (Alignment)align ); @@ -1201,9 +1201,7 @@ public class SWTInterface extends JPanel { selectedLocalAlign = localAlignIdList[0]; - //System.out.println("offline matching done. "); - - + //System.out.println("offline matching done. "); } //else for ""offline" } // getsource diff --git a/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/WSDialog.java b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/WSDialog.java new file mode 100644 index 00000000..c6505a89 --- /dev/null +++ b/plugins/neon/src/fr/inrialpes/exmo/align/plugin/neontk/WSDialog.java @@ -0,0 +1,157 @@ +/* + * $Id: View.java 860 2008-10-17 07:43:35Z cleduc $ + * + * Copyright (C) INRIA, 2007-2008 + * + * 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 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package fr.inrialpes.exmo.align.plugin.neontk; + + +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Dialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridLayout; + +import org.eclipse.swt.SWT; + +public class WSDialog extends Dialog { + private String message; + private String serverInput; + private String methodInput; + + public WSDialog(Shell parent) { + // Pass the default styles here + this(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL ); + } + + + public WSDialog(Shell parent, int style) { + // Let users override the default styles + super(parent, style); + setText("Parameters for matching"); + setMessage("Parameters for matching"); + } + + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + + public String getServerInput() { + return serverInput; + } + + public String getMethodInput() { + return methodInput; + } + + public void setServerInput(String input) { + this.serverInput = input; + } + public void setMethodInput(String input) { + this.methodInput = input; + } + + public String open() { + // Create the dialog window + Shell shell = new Shell(getParent(), getStyle()); + shell.setText(getText()); + createContents(shell); + shell.pack(); + shell.open(); + Display display = getParent().getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + // Return the entered value, or null + return serverInput; + } + + + private void createContents(final Shell shell) { + shell.setLayout(new GridLayout(3, true)); + + // Show the message + Label label = new Label(shell, SWT.NONE); + label.setText(message); + GridData data = new GridData(); + data.horizontalSpan = 6; + label.setLayoutData(data); + + // Display the input box for server + final Text server = new Text(shell, SWT.BORDER); + server.setText("http://kameleon.ijs.si/ontolight/ontolight.asmx"); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 6; + server.setLayoutData(data); + + // Display the input box for method + final Text wsmethod = new Text(shell, SWT.BORDER); + //text.setText(""); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 6; + wsmethod.setLayoutData(data); + + // Create the OK button and add a handler + // so that pressing it will set input + // to the entered value + Button ok = new Button(shell, SWT.PUSH); + ok.setText("OK"); + data = new GridData(GridData.FILL_HORIZONTAL); + ok.setLayoutData(data); + ok.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + serverInput = server.getText(); + methodInput = wsmethod.getText(); + shell.close(); + } + }); + + // Create the cancel button and add a handler + // so that pressing it will set input to null + Button cancel = new Button(shell, SWT.PUSH); + cancel.setText("Cancel"); + data = new GridData(GridData.FILL_HORIZONTAL); + cancel.setLayoutData(data); + cancel.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + serverInput = null; + methodInput = null; + shell.close(); + } + }); + + // Set the OK button as the default, so + // user can type input and press Enter + // to dismiss + shell.setDefaultButton(ok); + } + } + -- GitLab