Skip to content
Browse files

Fixed layout issue in view list.

  • Loading branch information...
1 parent 8942420 commit c7ef6a2df0e779cdf1a87ed9c655694e6b7b5fce @cderoove committed Jan 30, 2013
View
53 ExapusRAP/src/exapus/gui/util/FileDownloadDialog.java
@@ -0,0 +1,53 @@
+package exapus.gui.util;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+//from http://www.eclipse.org/forums/index.php/m/657553/
+public class FileDownloadDialog extends Dialog {
+ private Browser b;
+ private String url;
+
+ public FileDownloadDialog(Shell parent) {
+ super(parent);
+ }
+
+ public void setURL (String url) {
+ if (b != null && !b.isDisposed()) {
+ b.setUrl(url);
+ }
+ this.url = url;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Control control = super.createDialogArea(parent);
+ b = new Browser(parent, SWT.NONE);
+ if (url != null) {
+ b.setUrl(url);
+ }
+ return control;
+ }
+
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ return null;
+ }
+
+ @Override
+ protected int getShellStyle() {
+ return SWT.NO_TRIM;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setSize(1, 1);
+ newShell.setMinimized(true);
+ }
+}
+
View
28 ExapusRAP/src/exapus/gui/views/store/StoreView.java
@@ -1,10 +1,5 @@
package exapus.gui.views.store;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.xml.bind.JAXBException;
-
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
@@ -17,7 +12,6 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.window.Window;
import org.eclipse.rwt.RWT;
-import org.eclipse.rwt.widgets.ExternalBrowser;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
@@ -32,12 +26,15 @@
import exapus.gui.editors.view.ViewEditor;
import exapus.gui.editors.view.ViewEditorInput;
+import exapus.gui.util.FileDownloadDialog;
import exapus.gui.util.Util;
import exapus.model.store.Store;
import exapus.model.view.Perspective;
import exapus.model.view.View;
public class StoreView extends ViewPart implements IDoubleClickListener {
+ public StoreView() {
+ }
static {
RWT.getServiceManager().registerServiceHandler(ViewDownloadServiceHandler.ID, new ViewDownloadServiceHandler());
@@ -70,15 +67,23 @@ public String isValid(String newText) {
@Override
public void createPartControl(final Composite parent) {
parent.setLayout(new FillLayout());
+
listView = new ListViewer(parent);
listView.setContentProvider(new StoreListContentProvider());
listView.addDoubleClickListener(this);
listView.setInput(Store.getCurrent());
+
+ /*
+ * listView.getControl().setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
+
hidden = new Browser(parent, SWT.NONE);
+ //hidden.setBounds(0, 0, 0, 0);
hidden.setVisible(false);
- hidden.setSize(0, 0);
-
+ GridData hiddenGD = new GridData();
+ hiddenGD.exclude = true;
+ hidden.setLayoutData(hiddenGD);
+*/
Action newViewAction = new Action() {
@Override
@@ -134,8 +139,10 @@ public void run() {
Object selected = selection.getFirstElement();
if(selected instanceof View) {
View selectedView = (View) selected;
- String url = ViewDownloadServiceHandler.viewDownloadUrl(selectedView.getName());
- hidden.setUrl(url);
+ FileDownloadDialog dlg = new FileDownloadDialog(parent.getShell());
+ dlg.setURL(ViewDownloadServiceHandler.viewDownloadUrlBrowser(selectedView.getName()));
+ dlg.open();
+ dlg.close();
}
}
};
@@ -200,7 +207,6 @@ public void selectionChanged(SelectionChangedEvent event) {
}
});
-
}
@Override
View
20 ExapusRAP/src/exapus/gui/views/store/ViewDownloadServiceHandler.java
@@ -19,19 +19,31 @@
public static String ID = "viewDownloadServiceHandler";
- public static String viewDownloadUrl(String viewName) {
+ public static String viewDownloadUrlExternalBrowser(String viewName) {
+ StringBuilder url = new StringBuilder();
+ url.append(RWT.getRequest().getRequestURL());
+ appendHandlerParameter(url, viewName);
+ return RWT.getResponse().encodeURL(url.toString());
+
+ }
+
+ public static String viewDownloadUrlBrowser(String viewName) {
StringBuilder url = new StringBuilder();
url.append(RWT.getRequest().getContextPath());
url.append(RWT.getRequest().getServletPath());
+ appendHandlerParameter(url, viewName);
+ return RWT.getResponse().encodeURL(url.toString());
+ }
+
+
+ private static void appendHandlerParameter(StringBuilder url, String viewName) {
url.append("?");
url.append(IServiceHandler.REQUEST_PARAM );
url.append("="+ID);
url.append("&viewName=" );
url.append(viewName);
- return RWT.getResponse().encodeURL(url.toString());
}
-
-
+
public void service() throws IOException, ServletException {
String viewName = RWT.getRequest().getParameter("viewName");
File xmlFile = Store.getCurrent().xmlForRegisteredView(viewName);

0 comments on commit c7ef6a2

Please sign in to comment.
Something went wrong with that request. Please try again.