Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2013-10-17 21:11:54 +0000
committerLars Vogel2013-10-21 08:17:35 +0000
commita8341a9fc345415fb34e8defc58f2b9e04a3bf0a (patch)
tree95da16ac47c3cf88238b3466dcfba24463c0e46e
parent258f3de49e8bfc6cb09a907ac2138b111c03c485 (diff)
downloadorg.eclipse.e4.tools-a8341a9fc345415fb34e8defc58f2b9e04a3bf0a.tar.gz
org.eclipse.e4.tools-a8341a9fc345415fb34e8defc58f2b9e04a3bf0a.tar.xz
org.eclipse.e4.tools-a8341a9fc345415fb34e8defc58f2b9e04a3bf0a.zip
Bug 419770 - Update templates for e4 wizard
Change-Id: I2349e16ef3c27a2ceca25ebf9ca9cda5ca539f4f Signed-off-by: Lars Vogel <Lars.Vogel@gmail.com>
-rw-r--r--bundles/org.eclipse.e4.tools/templates/src/handlers/AboutHandler.java8
-rw-r--r--bundles/org.eclipse.e4.tools/templates/src/handlers/OpenHandler.java11
-rw-r--r--bundles/org.eclipse.e4.tools/templates/src/handlers/QuitHandler.java13
-rw-r--r--bundles/org.eclipse.e4.tools/templates/src/handlers/SaveHandler.java56
-rw-r--r--bundles/org.eclipse.e4.tools/templates/src/parts/SamplePart.java37
5 files changed, 51 insertions, 74 deletions
diff --git a/bundles/org.eclipse.e4.tools/templates/src/handlers/AboutHandler.java b/bundles/org.eclipse.e4.tools/templates/src/handlers/AboutHandler.java
index dce5d100..df0b8ed6 100644
--- a/bundles/org.eclipse.e4.tools/templates/src/handlers/AboutHandler.java
+++ b/bundles/org.eclipse.e4.tools/templates/src/handlers/AboutHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010 - 2013 IBM Corporation and others.
* 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
@@ -7,19 +7,17 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <lars.Vogel@gmail.com> - Bug 419770
*******************************************************************************/
package @@packageName@@;
-import javax.inject.Named;
-
import org.eclipse.e4.core.di.annotations.Execute;
-import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
public class AboutHandler {
@Execute
- public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
+ public void execute(Shell shell) {
MessageDialog.openInformation(shell, "About", "Eclipse 4 Application example.");
}
}
diff --git a/bundles/org.eclipse.e4.tools/templates/src/handlers/OpenHandler.java b/bundles/org.eclipse.e4.tools/templates/src/handlers/OpenHandler.java
index 923e7c69..fe13432b 100644
--- a/bundles/org.eclipse.e4.tools/templates/src/handlers/OpenHandler.java
+++ b/bundles/org.eclipse.e4.tools/templates/src/handlers/OpenHandler.java
@@ -7,24 +7,17 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <lars.Vogel@gmail.com> - Bug 419770
*******************************************************************************/
package @@packageName@@;
-import java.lang.reflect.InvocationTargetException;
-
-import javax.inject.Named;
-
-import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
-import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
-
public class OpenHandler {
@Execute
- public void execute(
- @Named(IServiceConstants.ACTIVE_SHELL) Shell shell){
+ public void execute(Shell shell){
FileDialog dialog = new FileDialog(shell);
dialog.open();
}
diff --git a/bundles/org.eclipse.e4.tools/templates/src/handlers/QuitHandler.java b/bundles/org.eclipse.e4.tools/templates/src/handlers/QuitHandler.java
index f49e7f88..3b1929b5 100644
--- a/bundles/org.eclipse.e4.tools/templates/src/handlers/QuitHandler.java
+++ b/bundles/org.eclipse.e4.tools/templates/src/handlers/QuitHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010 - 2013 IBM Corporation and others.
* 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
@@ -7,24 +7,19 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <lars.Vogel@gmail.com> - Bug 419770
*******************************************************************************/
package @@packageName@@;
-import java.lang.reflect.InvocationTargetException;
-
-import javax.inject.Named;
-
-import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
-import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.IWorkbench;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
+
public class QuitHandler {
@Execute
- public void execute(IWorkbench workbench,
- @Named(IServiceConstants.ACTIVE_SHELL) Shell shell){
+ public void execute(IWorkbench workbench, Shell shell){
if (MessageDialog.openConfirm(shell, "Confirmation",
"Do you want to exit?")) {
workbench.close();
diff --git a/bundles/org.eclipse.e4.tools/templates/src/handlers/SaveHandler.java b/bundles/org.eclipse.e4.tools/templates/src/handlers/SaveHandler.java
index 02963726..1127141e 100644
--- a/bundles/org.eclipse.e4.tools/templates/src/handlers/SaveHandler.java
+++ b/bundles/org.eclipse.e4.tools/templates/src/handlers/SaveHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010 - 2013 IBM Corporation and others.
* 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
@@ -7,58 +7,26 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <lars.Vogel@gmail.com> - Bug 419770
*******************************************************************************/
package @@packageName@@;
-import java.lang.reflect.InvocationTargetException;
-
-import javax.inject.Named;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.e4.core.contexts.ContextInjectionFactory;
-import org.eclipse.e4.core.contexts.IEclipseContext;
-import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.CanExecute;
-import org.eclipse.e4.ui.model.application.MContribution;
-import org.eclipse.e4.ui.model.application.ui.MDirtyable;
-import org.eclipse.e4.ui.services.IServiceConstants;
-//import org.eclipse.e4.ui.workbench.Persist;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
public class SaveHandler {
+
@CanExecute
- public boolean canExecute(
- @Named(IServiceConstants.ACTIVE_PART) MDirtyable dirtyable) {
- if (dirtyable == null) {
- return false;
+ public boolean canExecute(EPartService partService) {
+ if (partService != null) {
+ return !partService.getDirtyParts().isEmpty();
}
- return dirtyable.isDirty();
+ return false;
}
@Execute
- public void execute(
- IEclipseContext context,
- @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
- @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution)
- throws InvocationTargetException, InterruptedException {
- final IEclipseContext pmContext = context.createChild();
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- dialog.open();
- dialog.run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- pmContext.set(IProgressMonitor.class.getName(), monitor);
- if (contribution != null) {
- Object clientObject = contribution.getObject();
-// ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$
-// pmContext, null);
- }
- }
- });
-
- pmContext.dispose();
+ public void execute(EPartService partService) {
+ partService.saveAll(false);
}
-}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools/templates/src/parts/SamplePart.java b/bundles/org.eclipse.e4.tools/templates/src/parts/SamplePart.java
index 0d637480..28ae4816 100644
--- a/bundles/org.eclipse.e4.tools/templates/src/parts/SamplePart.java
+++ b/bundles/org.eclipse.e4.tools/templates/src/parts/SamplePart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010 - 2013 IBM Corporation and others.
* 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
@@ -7,31 +7,49 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lars Vogel <lars.Vogel@gmail.com> - Bug 419770
*******************************************************************************/
package @@packageName2@@;
import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
import org.eclipse.e4.ui.di.Focus;
+import org.eclipse.e4.ui.di.Persist;
+import org.eclipse.e4.ui.model.application.ui.MDirtyable;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
public class SamplePart {
- private Label label;
+ private Text txtInput;
private TableViewer tableViewer;
+ @Inject
+ private MDirtyable dirty;
+
@PostConstruct
public void createComposite(Composite parent) {
- parent.setLayout(new GridLayout());
+ parent.setLayout(new GridLayout(1, false));
- label = new Label(parent, SWT.NONE);
- label.setText("Sample table");
+ txtInput = new Text(parent, SWT.BORDER);
+ txtInput.setMessage("Enter text to mark part as dirty");
+ txtInput.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ dirty.setDirty(true);
+ }
+ });
+ txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tableViewer = new TableViewer(parent);
+
tableViewer.add("Sample item 1");
tableViewer.add("Sample item 2");
tableViewer.add("Sample item 3");
@@ -44,4 +62,9 @@ public class SamplePart {
public void setFocus() {
tableViewer.getTable().setFocus();
}
-}
+
+ @Persist
+ public void save() {
+ dirty.setDirty(false);
+ }
+} \ No newline at end of file

Back to the top