List of usage examples for org.eclipse.jface.window Window getDefaultOrientation
public static int getDefaultOrientation()
From source file:com.vectrace.MercurialEclipse.dialogs.CommitDialog.java
License:Open Source License
private void openSash() { IProgressMonitor pm = this.monitor; monitor.setVisible(true);// w w w .j av a 2s .c o m pm.beginTask("Loading amend data.", 2); // only one root allowed when amending Map<HgRoot, List<IResource>> map = ResourceUtils.groupByRoot(resourcesToCommit); if (map.size() > 1) { setMessage(Messages.getString("CommitDialog.amendingOnlyForOneRoot")); amendCheckbox.setEnabled(false); amendCheckbox.setSelection(false); } pm.done(); monitor.setVisible(false); // set old commit message IDocument msg = commitTextDocument; if ("".equals(msg.get()) || msg.get().equals(DEFAULT_COMMIT_MESSAGE)) { msg.set(currentChangeset.getComment()); } // create tray controls ChangesetInfoTray t = new ChangesetInfoTray(currentChangeset); final Shell shell = getShell(); leftSeparator = new Label(shell, SWT.SEPARATOR | SWT.VERTICAL); leftSeparator.setLayoutData(new GridData(GridData.FILL_VERTICAL)); sash = new Sash(shell, SWT.VERTICAL); sash.setLayoutData(new GridData(GridData.FILL_VERTICAL)); rightSeparator = new Label(shell, SWT.SEPARATOR | SWT.VERTICAL); rightSeparator.setLayoutData(new GridData(GridData.FILL_VERTICAL)); trayControl = t.createContents(shell); // calculate width Rectangle clientArea = shell.getClientArea(); final GridData data = new GridData(GridData.FILL_VERTICAL); data.widthHint = trayControl.computeSize(clientArea.width * 3 / 4, clientArea.height).x; trayControl.setLayoutData(data); int trayWidth = leftSeparator.computeSize(SWT.DEFAULT, clientArea.height).x + sash.computeSize(SWT.DEFAULT, clientArea.height).x + rightSeparator.computeSize(SWT.DEFAULT, clientArea.height).x + data.widthHint; Rectangle bounds = shell.getBounds(); shell.setBounds(bounds.x - ((Window.getDefaultOrientation() == SWT.RIGHT_TO_LEFT) ? trayWidth : 0), bounds.y, bounds.width + trayWidth, bounds.height); sash.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { if (event.detail != SWT.DRAG) { Rectangle rect = shell.getClientArea(); int newWidth = rect.width - event.x - (sash.getSize().x + rightSeparator.getSize().x); if (newWidth != data.widthHint) { data.widthHint = newWidth; shell.layout(); } } } }); this.tray = t; }
From source file:com.vectrace.MercurialEclipse.dialogs.CommitDialog.java
License:Open Source License
private void closeSash() { if (tray == null) { throw new IllegalStateException("Tray was not open"); //$NON-NLS-1$ }/*ww w. jav a2 s .c om*/ int trayWidth = trayControl.getSize().x + leftSeparator.getSize().x + sash.getSize().x + rightSeparator.getSize().x; trayControl.dispose(); trayControl = null; tray = null; leftSeparator.dispose(); leftSeparator = null; rightSeparator.dispose(); rightSeparator = null; sash.dispose(); sash = null; Shell shell = getShell(); Rectangle bounds = shell.getBounds(); shell.setBounds(bounds.x + ((Window.getDefaultOrientation() == SWT.RIGHT_TO_LEFT) ? trayWidth : 0), bounds.y, bounds.width - trayWidth, bounds.height); }
From source file:lost.tok.print.WrappingPrinter.java
License:Open Source License
/** * Prints the file//from w ww .j a va2 s . c o m */ public void print() { // Start the print job if (printer.startJob(fileName)) { // Determine print area, with margins bounds = computePrintArea(printer); xPos = bounds.x; yPos = bounds.y; int style = Window.getDefaultOrientation(); // Create the GC gc = new GC(printer, style); //MICHAL // gc.getFont().getFontData()[0].setHeight(14); // Determine line height lineHeight = gc.getFontMetrics().getHeight(); // Determine tab width--use three spaces for tabs int tabWidth = gc.stringExtent(" ").x; // Print the text printer.startPage(); Image image = ImageManager.getImage(ImageType.TREE_BIG); gc.drawImage(image, xPos, yPos); yPos += image.getBounds().height; buf = new StringBuffer(); char c; for (int i = 0, n = contents.length(); i < n; i++) { // Get the next character c = contents.charAt(i); // Check for newline if (c == '\n') { printBuffer(); printNewline(); } // Check for tab else if (c == '\t') { xPos += tabWidth; } else { buf.append(c); // Check for space if (Character.isWhitespace(c)) { printBuffer(); } } } printer.endPage(); printer.endJob(); gc.dispose(); } }
From source file:org.bonitasoft.studio.application.splash.BOSSplashHandler.java
License:Open Source License
@Override public IProgressMonitor getBundleProgressMonitor() { if (monitor == null) { if (getSplash() == null) { return null; }/*from w w w . j a va 2 s. co m*/ Composite parent = new Composite(getSplash(), Window.getDefaultOrientation()); Point size = getSplash().getSize(); parent.setBounds(new Rectangle(0, 0, size.x, size.y)); monitor = new CustomAbsolutePositionProgressMonitorPart(parent); monitor.setSize(size); if (progressRect != null) { monitor.getProgressIndicator().setBounds(progressRect); } else { monitor.getProgressIndicator().setVisible(false); } if (messageRect != null) { monitor.getProgressText().setBounds(messageRect); } else { monitor.getProgressText().setVisible(false); } monitor.getProgressText().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); monitor.setBackgroundMode(SWT.INHERIT_FORCE); monitor.setBackgroundImage(getSplash().getShell().getBackgroundImage()); } return monitor; }
From source file:org.ebayopensource.vjet.eclipse.internal.ui.templates.VjoTemplateCompletionProcessor.java
License:Open Source License
protected IInformationControlCreator getInformationControlCreator() { int orientation = Window.getDefaultOrientation(); IEditorPart editor = getContext().getEditor(); if (editor == null) editor = DLTKUIPlugin.getActivePage().getActiveEditor(); if (editor instanceof IWorkbenchPartOrientation) orientation = ((IWorkbenchPartOrientation) editor).getOrientation(); IDLTKLanguageToolkit toolkit = null; toolkit = DLTKLanguageManager.getLanguageToolkit(getContext().getLanguageNatureID()); if ((toolkit == null) && (editor instanceof ScriptEditor)) toolkit = ((ScriptEditor) editor).getLanguageToolkit(); return new TemplateInformationControlCreator(orientation, toolkit); }
From source file:org.eclipse.birt.report.designer.internal.ui.util.UIUtil.java
License:Open Source License
/** * @return Creates a shell according to default window orientation *///from w w w. ja v a 2 s . c om public static Shell createDefaultShell() { return new Shell(SWT.SHELL_TRIM | Window.getDefaultOrientation()); }
From source file:org.eclipse.birt.report.viewer.browsers.embedded.EmbeddedBrowser.java
License:Open Source License
/** * Constructor for embedded browser.//w ww. j a va 2 s . c om */ public EmbeddedBrowser() { store = ViewerPlugin.getDefault().getPluginPreferences(); shell = new Shell(SWT.SHELL_TRIM | Window.getDefaultOrientation()); initializeShell(shell); shell.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { browser.close(); } }); shell.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { if (!shell.getMaximized()) { Point location = shell.getLocation(); x = location.x; y = location.y; } } public void controlResized(ControlEvent e) { if (!shell.getMaximized()) { Point size = shell.getSize(); w = size.x; h = size.y; } } }); shell.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { // save position store.setValue(BROWSER_X, Integer.toString(x)); store.setValue(BROWSER_Y, Integer.toString(y)); store.setValue(BROWSER_WIDTH, Integer.toString(w)); store.setValue(BROWSER_HEIGTH, Integer.toString(h)); store.setValue(BROWSER_MAXIMIZED, (Boolean.valueOf(shell.getMaximized()).toString())); } }); if (Constants.OS_LINUX.equalsIgnoreCase(Platform.getOS())) { browser = new Browser(shell, SWT.MOZILLA); } else { browser = new Browser(shell, SWT.NONE); } initialize(shell.getDisplay(), browser); // use saved location and size x = store.getInt(BROWSER_X); y = store.getInt(BROWSER_Y); w = store.getInt(BROWSER_WIDTH); h = store.getInt(BROWSER_HEIGTH); if (w == 0 || h == 0) { // first launch, use default size w = 1024; h = 768; x = shell.getLocation().x; y = shell.getLocation().y; } setSafeBounds(shell, x, y, w, h); if (store.getBoolean(BROWSER_MAXIMIZED)) { shell.setMaximized(true); } shell.addControlListener(new ControlListener() { public void controlMoved(ControlEvent e) { if (!shell.getMaximized()) { Point location = shell.getLocation(); x = location.x; y = location.y; } } public void controlResized(ControlEvent e) { if (!shell.getMaximized()) { Point size = shell.getSize(); w = size.x; h = size.y; } } }); shell.open(); // browser.setUrl("about:blank"); browser.addLocationListener(new LocationListener() { public void changing(LocationEvent e) { // hack to know when help webapp needs modal window modalRequestTime = 0; if (e.location != null && e.location.startsWith("javascript://needModal")) //$NON-NLS-1$ { modalRequestTime = System.currentTimeMillis(); } } public void changed(LocationEvent e) { // Do nothing } }); }
From source file:org.eclipse.birt.report.viewer.browsers.embedded.EmbeddedBrowser.java
License:Open Source License
/** * Constructor embedded browser.//from w w w. j a v a2s . c om * * @param event * @param parent * Shell or null */ public EmbeddedBrowser(WindowEvent event, Shell parent) { if (parent == null) { shell = new Shell(SWT.SHELL_TRIM | Window.getDefaultOrientation()); } else { shell = new Shell(parent, SWT.PRIMARY_MODAL | SWT.DIALOG_TRIM); } initializeShell(shell); Browser browser = null; if (Constants.OS_LINUX.equalsIgnoreCase(Platform.getOS())) { browser = new Browser(shell, SWT.MOZILLA); } else { browser = new Browser(shell, SWT.NONE); } initialize(shell.getDisplay(), browser); event.browser = browser; browser.addLocationListener(new LocationListener() { public void changing(LocationEvent e) { // hack to know when help webapp needs modal window modalRequestTime = 0; if (e.location != null && e.location.startsWith("javascript://needModal")) //$NON-NLS-1$ { modalRequestTime = System.currentTimeMillis(); } } public void changed(LocationEvent e) { // Do nothing } }); }
From source file:org.eclipse.birt.report.viewer.utilities.WebViewer.java
License:Open Source License
private static Map<String, String> prepareCommonURLParams(String format, String resourceFolder, String maxrows, String maxrowlevels, String maxcolumnlevels) { String timeZone = ViewerPlugin.getDefault().getPluginPreferences().getString(USER_TIME_ZONE); if ("".equals(timeZone)) //$NON-NLS-1$ {/*from w w w. j ava 2 s . c o m*/ timeZone = null; } String locale = ViewerPlugin.getDefault().getPluginPreferences().getString(USER_LOCALE); if (LOCALE_TABLE.containsKey(locale)) { locale = LOCALE_TABLE.get(locale); } else { if ("".equals(locale)) //$NON-NLS-1$ { locale = null; } else { try { locale = URLEncoder.encode(locale, UTF_8); } catch (UnsupportedEncodingException e) { locale = null; LogUtil.logWarning(e.getLocalizedMessage(), e); } } } boolean bSVGFlag = Platform.getPreferencesService().getBoolean(ViewerPlugin.PLUGIN_ID, SVG_FLAG, true, null); // cube memory size String cubeMemorySize = ViewerPlugin.getDefault().getPluginPreferences() .getString(PREVIEW_MAXINMEMORYCUBESIZE); // read rtl value from the preferences boolean rtl = false; String bidiOrientation = ViewerPlugin.getDefault().getPluginPreferences().getString(BIDI_ORIENTATION); if (bidiOrientation == null) { bidiOrientation = BIDI_ORIENTATION_AUTO; } if (BIDI_ORIENTATION_LTR.equals(bidiOrientation)) { rtl = false; } else if (BIDI_ORIENTATION_RTL.equals(bidiOrientation)) { rtl = true; } else { // detect rtl from eclipse rtl = (Window.getDefaultOrientation() == SWT.RIGHT_TO_LEFT); } String masterPageContent = ViewerPlugin.getDefault().getPluginPreferences().getString(MASTER_PAGE_CONTENT); boolean bMasterPageContent = true; if ("false".equalsIgnoreCase(masterPageContent)) //$NON-NLS-1$ { bMasterPageContent = false; } // handle resource folder encoding String encodedResourceFolder = null; if (resourceFolder != null) { try { encodedResourceFolder = URLEncoder.encode(resourceFolder, UTF_8); } catch (UnsupportedEncodingException e) { LogUtil.logWarning(e.getLocalizedMessage(), e); } } if (encodedResourceFolder == null) { encodedResourceFolder = ""; //$NON-NLS-1$ } // workaround for postscript/doc/docx/ppt/pptx/odp/ods/odt formats, force "Content-Disposition" as // "attachment" String asattachment = null; if (POSTSCRIPT.equalsIgnoreCase(format) || DOC.equalsIgnoreCase(format) || DOCX.equalsIgnoreCase(format) || PPT.equalsIgnoreCase(format) || PPTX.equalsIgnoreCase(format) || ODP.equalsIgnoreCase(format) || ODS.equalsIgnoreCase(format) || ODT.equalsIgnoreCase(format)) { asattachment = "&__asattachment=true"; //$NON-NLS-1$ } // get the local DPI setting int dpi = Toolkit.getDefaultToolkit().getScreenResolution(); LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); if (format != null) { params.put(ParameterAccessor.PARAM_FORMAT, format); } params.put(ParameterAccessor.PARAM_SVG, String.valueOf(bSVGFlag)); if (locale != null) { params.put(ParameterAccessor.PARAM_LOCALE, locale); } if (timeZone != null) { try { params.put(ParameterAccessor.PARAM_TIMEZONE, URLEncoder.encode(timeZone, UTF_8)); } catch (UnsupportedEncodingException e) { LogUtil.logWarning(e.getLocalizedMessage(), e); } } params.put(ParameterAccessor.PARAM_MASTERPAGE, String.valueOf(bMasterPageContent)); params.put(ParameterAccessor.PARAM_RTL, String.valueOf(rtl)); if (!StringUtil.isBlank(maxrows)) { params.put(ParameterAccessor.PARAM_MAXROWS, maxrows.trim()); } // if ( !StringUtil.isBlank( maxrowlevels ) ) // { // params.put( ParameterAccessor.PARAM_MAXCUBE_ROWLEVELS, // maxrowlevels.trim( ) ); // } // if ( !StringUtil.isBlank( maxcolumnlevels ) ) // { // params.put( ParameterAccessor.PARAM_MAXCUBE_COLUMNLEVELS, // maxcolumnlevels.trim( ) ); // } if (!StringUtil.isBlank(cubeMemorySize)) { params.put(ParameterAccessor.PARAM_CUBEMEMSIZE, cubeMemorySize.trim()); } params.put(ParameterAccessor.PARAM_RESOURCE_FOLDER, encodedResourceFolder); if (asattachment != null) { params.put(ParameterAccessor.PARAM_AS_ATTACHMENT, "true"); //$NON-NLS-1$ } // Do not append dpi for HTML viewer since actual dpi will be set in // viewer side if (!(HTML.equalsIgnoreCase(format))) { params.put(ParameterAccessor.PARAM_DPI, String.valueOf(dpi)); } return params; }
From source file:org.eclipse.compare.codereview.compareEditor.RefacContentMergeViewer.java
License:Open Source License
/** * Builds the SWT controls for the three areas of a compare/merge viewer. * <p>//from www .ja v a 2 s. c om * Calls the hooks <code>createControls</code> and <code>createToolItems</code> * to let subclasses build the specific content areas and to add items to * an enclosing toolbar. * <p> * This method must only be called in the constructor of subclasses. * * @param parent the parent control * @return the new control */ protected final Control buildControl(Composite parent) { fComposite = new Composite(parent, fStyles | SWT.LEFT_TO_RIGHT) { // we force a specific direction public boolean setFocus() { return RefacContentMergeViewer.this.handleSetFocus(); } }; fComposite.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle()); hookControl(fComposite); // hook help & dispose listener fComposite.setLayout(new ContentMergeViewerLayout()); int style = SWT.SHADOW_OUT; fAncestorLabel = new CLabel(fComposite, style | Window.getDefaultOrientation()); fLeftLabel = new CLabel(fComposite, style | Window.getDefaultOrientation()); new Resizer(fLeftLabel, VERTICAL); fDirectionLabel = new CLabel(fComposite, style); fDirectionLabel.setAlignment(SWT.CENTER); new Resizer(fDirectionLabel, HORIZONTAL | VERTICAL); fRightLabel = new CLabel(fComposite, style | Window.getDefaultOrientation()); new Resizer(fRightLabel, VERTICAL); if (fCenter == null || fCenter.isDisposed()) fCenter = createCenterControl(fComposite); createControls(fComposite); fHandlerService = CompareHandlerService.createFor(getCompareConfiguration().getContainer(), fComposite.getShell()); initializeToolbars(parent); return fComposite; }