summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-24 13:37:36 (EDT)
committerEike Stepper2007-07-24 13:37:36 (EDT)
commitb75b9f81b7b134c9662c92004768a1306815b4cc (patch)
tree29ba1dd7dcb81dd9724172e8c0360feb1e18a259
parent454c2c4b493a7be5562fe83314688cddb46e8f49 (diff)
downloadcdo-b75b9f81b7b134c9662c92004768a1306815b4cc.zip
cdo-b75b9f81b7b134c9662c92004768a1306815b4cc.tar.gz
cdo-b75b9f81b7b134c9662c92004768a1306815b4cc.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java67
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackageAction.java43
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java3
-rw-r--r--plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java135
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java6
8 files changed, 264 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml b/plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml
index b032bee..0451548 100644
--- a/plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.tests.model1/plugin.xml
@@ -13,7 +13,8 @@
<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri = "http://www.eclipse.org/emf/CDO/tests/model1/1.0.0"
- class = "org.eclipse.emf.cdo.tests.model1.Model1Package"/>
+ class = "org.eclipse.emf.cdo.tests.model1.Model1Package"
+ genModel = "model/model1.genmodel"/>
</extension>
<extension point="org.eclipse.emf.cdo.persistent_package">
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java
new file mode 100644
index 0000000..3f556de
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterCDOPackageAction.java
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.internal.ui.bundle.OM;
+
+import org.eclipse.net4j.internal.util.collection.PreferenceHistory;
+import org.eclipse.net4j.ui.widgets.HistoryInputDialog;
+import org.eclipse.net4j.util.collection.IHistory;
+
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @author Eike Stepper
+ */
+public class RegisterCDOPackageAction extends RegisterPackageAction
+{
+ public static final IHistory<String> HISTORY = new PreferenceHistory(OM.PREF_HISTORY_REGISTER_CDO_PACKAGE);
+
+ private static final String TITLE = "Register CDO Package";
+
+ public RegisterCDOPackageAction(IWorkbenchPage page, CDOSession session)
+ {
+ super(page, TITLE, "Register a package generated for CDO", null, session);
+ }
+
+ @Override
+ protected EPackage getEPackage(IWorkbenchPage page, CDOSession session)
+ {
+ Shell shell = page.getWorkbenchWindow().getShell();
+ for (;;)
+ {
+ InputDialog dialog = new HistoryInputDialog(shell, TITLE, "Enter a package URI:", HISTORY, null);
+ if (dialog.open() != InputDialog.OK)
+ {
+ return null;
+ }
+
+ String uri = dialog.getValue();
+ EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(uri);
+ if (ePackage != null)
+ {
+ HISTORY.add(uri);
+ return ePackage;
+ }
+
+ if (!MessageDialog.openQuestion(shell, TITLE, "Package " + uri + " not found.\nTry again?"))
+ {
+ return null;
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackageAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackageAction.java
new file mode 100644
index 0000000..dc47dac
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterPackageAction.java
@@ -0,0 +1,43 @@
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.util.CDOPackageRegistry;
+
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class RegisterPackageAction extends SessionAction
+{
+ private EPackage ePackage;
+
+ public RegisterPackageAction(IWorkbenchPage page, String text, String toolTipText, ImageDescriptor image,
+ CDOSession session)
+ {
+ super(page, text, toolTipText, image, session);
+ }
+
+ @Override
+ protected void preRun(IWorkbenchPage page) throws Exception
+ {
+ ePackage = getEPackage(page, getSession());
+ if (ePackage == null)
+ {
+ cancel();
+ }
+ }
+
+ @Override
+ protected void doRun(IWorkbenchPage page, IProgressMonitor monitor) throws Exception
+ {
+ CDOPackageRegistry packageRegistry = getSession().getPackageRegistry();
+ packageRegistry.putEPackage(ePackage);
+ }
+
+ protected abstract EPackage getEPackage(IWorkbenchPage page, CDOSession session);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
index a6e5a42..7ed1083 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
@@ -17,6 +17,8 @@ import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.OSGiActivator;
import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.pref.OMPreference;
+import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.net4j.util.om.trace.OMTracer;
/**
@@ -32,6 +34,11 @@ public abstract class OM
public static final OMLogger LOG = BUNDLE.logger();
+ public static final OMPreferences PREFS = BUNDLE.preferences();
+
+ public static final OMPreference<String[]> PREF_HISTORY_REGISTER_CDO_PACKAGE = PREFS
+ .initArray("history.register.cdo.package");
+
static void start() throws Exception
{
IRepositoryManager.INSTANCE.addRepository("repo1", new NOOPStore());
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
index f8303a4..2edaaee 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
@@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.internal.ui.actions.OpenAuditAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenTransactionAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenViewAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenViewEditorAction;
+import org.eclipse.emf.cdo.internal.ui.actions.RegisterCDOPackageAction;
import org.eclipse.emf.cdo.internal.ui.views.CDOViewHistory.Entry;
import org.eclipse.net4j.IConnector;
@@ -262,6 +263,8 @@ public class CDOItemProvider extends ContainerItemProvider
manager.add(new OpenViewAction(page, session));
manager.add(new OpenAuditAction(page, session));
manager.add(new Separator());
+ manager.add(new RegisterCDOPackageAction(page, session));
+ manager.add(new Separator());
manager.add(new CloseSessionAction(page, session));
}
diff --git a/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF
index e620497..80a85cb 100644
--- a/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.ui/META-INF/MANIFEST.MF
@@ -18,4 +18,5 @@ Export-Package: org.eclipse.net4j.internal.ui;version="0.8.0",
org.eclipse.net4j.ui;version="0.8.0",
org.eclipse.net4j.ui.actions;version="0.8.0",
org.eclipse.net4j.ui.views;version="0.8.0",
+ org.eclipse.net4j.ui.widgets;version="0.8.0",
org.eclipse.net4j.ui.wizards;version="0.8.0"
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java
new file mode 100644
index 0000000..fa85e8f
--- /dev/null
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryInputDialog.java
@@ -0,0 +1,135 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.ui.widgets;
+
+import org.eclipse.net4j.util.collection.IHistory;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Eike Stepper
+ */
+public class HistoryInputDialog extends InputDialog
+{
+ private static final String EMPTY = "";
+
+ private IHistory<String> history;
+
+ private String value = EMPTY;
+
+ private HistoryText historyText;
+
+ public HistoryInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, IHistory<String> history,
+ IInputValidator validator)
+ {
+ super(parentShell, dialogTitle, dialogMessage, history.getMostRecent(), validator);
+ this.history = history;
+ value = super.getValue();
+ }
+
+ public IHistory<String> getHistory()
+ {
+ return history;
+ }
+
+ public HistoryText getHistoryText()
+ {
+ return historyText;
+ }
+
+ @Override
+ public String getValue()
+ {
+ return value;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ Composite composite = (Composite)super.createDialogArea(parent);
+ Text text = getText();
+ text.setVisible(false);
+ text.setEnabled(false);
+
+ historyText = new HistoryText(composite, SWT.BORDER, history);
+ historyText.moveAbove(text);
+ historyText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+ historyText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ validateInput();
+ }
+ });
+
+ text.addFocusListener(new FocusAdapter()
+ {
+ @Override
+ public void focusGained(FocusEvent e)
+ {
+ historyText.setFocus();
+ }
+ });
+
+ composite.getShell().layout(true); // XXX
+ return composite;
+ }
+
+ @Override
+ protected void buttonPressed(int buttonId)
+ {
+ super.buttonPressed(buttonId);
+ if (buttonId == IDialogConstants.OK_ID)
+ {
+ value = historyText.getText();
+ }
+ else
+ {
+ value = null;
+ }
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ super.createButtonsForButtonBar(parent);
+ historyText.setFocus();
+ if (value != null)
+ {
+ historyText.setText(value);
+ }
+ }
+
+ @Override
+ protected void validateInput()
+ {
+ String errorMessage = null;
+ if (getValidator() != null)
+ {
+ errorMessage = getValidator().isValid(historyText.getText());
+ }
+ // Bug 16256: important not to treat "" (blank error) the same as null
+ // (no error)
+ setErrorMessage(errorMessage);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java
index 0cb2451..2df43f8 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/widgets/HistoryText.java
@@ -190,6 +190,12 @@ public class HistoryText extends Composite
combo.setTextLimit(limit);
}
+ @Override
+ public boolean setFocus()
+ {
+ return combo.setFocus();
+ }
+
public boolean isDropped()
{
if (droppedMethod != null)