Révision 2428

tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 2428)
178 178
	/**
179 179
	 * installed extensions
180 180
	 */
181
	protected HashSet<TXMEditorExtension<T>> extensions = new HashSet<TXMEditorExtension<T>>();
181
	protected HashSet<TXMEditorExtension<T>> extensions = new HashSet<>();
182 182
	
183 183
	
184 184
	/**
......
202 202
	 * Default constructor.
203 203
	 */
204 204
	public TXMEditor() {
205
		
206 205
		super();
207 206
	}
208 207
	
......
212 211
	 * @param result
213 212
	 */
214 213
	public TXMEditor(TXMResult result) {
215
		
216
		this(new TXMResultEditorInput<TXMResult>(result));
214
		this(new TXMResultEditorInput<>(result));
217 215
	}
218 216
	
219 217
	/**
......
222 220
	 * @param editorInput
223 221
	 */
224 222
	public TXMEditor(TXMResultEditorInput<TXMResult> editorInput) {
225
		
226 223
		this.setInput(editorInput); // FIXME: SJ: the input is defined twice, on time here and one time in init(), need to see if we still need the assignment here in the constructor
227 224
	}
228 225
	
229 226
	@Override
230 227
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
231
		
232 228
		this.setSite(site);
233 229
		this.setInput(input);
234 230
		this.result = this.getEditorInput().getResult(); // store result for debug purpose
......
247 243
	 * Initializes plug-ins extensions.
248 244
	 */
249 245
	public void initExtensions() {
250
		
251 246
		IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TXMEditorExtension.EXTENSION_ID);
252 247
		if (config.length > 0) {
253 248
			
......
291 286
		IPartListener2 pl = new IPartListener2() {
292 287
			
293 288
			// ... Other methods
289
			@Override
294 290
			public void partClosed(IWorkbenchPartReference partRef) {
295 291
				
296 292
				// if (getResult() != null) {
......
349 345
	 * @return
350 346
	 */
351 347
	public GLComposite getFirstLineComposite() {
352
		
353 348
		return firstLineComposite;
354 349
	}
355 350
	
......
360 355
	 * @return
361 356
	 */
362 357
	public Shell getShell() {
363
		
364 358
		if (parent != null && !parent.isDisposed()) {
365 359
			return parent.getShell();
366 360
		}
......
372 366
	 * @return the composite displayed before the toptoolbar, containing the minimal parameters widgets
373 367
	 */
374 368
	public GLComposite getMainParametersComposite() {
375
		
376 369
		return mainParametersComposite;
377 370
	}
378 371
	
......
510 503
		
511 504
	}
512 505
	
506
	@Override
513 507
	public void setLocked(boolean b) {
514
		
515 508
		this.locked = b;
516 509
		this.firstLineComposite.setEnabled(!b);
517 510
	}
518 511
	
519 512
	public boolean isLocked() {
520
		
521 513
		return locked;
522 514
	}
523 515
	
......
544 536
		
545 537
		if (!step.startsWith("notify")) return; //$NON-NLS-1$
546 538
		
547
		ArrayList<TXMEditorExtension<T>> errors = new ArrayList<TXMEditorExtension<T>>();
539
		ArrayList<TXMEditorExtension<T>> errors = new ArrayList<>();
548 540
		for (final TXMEditorExtension<T> ext : extensions) {
549 541
			// ISafeRunnable runnable = new ISafeRunnable() {
550 542
			// @Override
......
591 583
	 * @return the composite that contains the default Bottom toolbar.
592 584
	 */
593 585
	public Composite getBottomToolBarContainer() {
594
		
595 586
		return bottomToolBarContainer;
596 587
	}
597 588
	
......
601 592
	 * @return the default Top toolbar of TXMEditors
602 593
	 */
603 594
	public TXMEditorToolBar getTopToolbar() {
604
		
605 595
		return topToolBar;
606 596
	}
607 597
	
......
612 602
	 * @return
613 603
	 */
614 604
	public GLComposite getResultArea() {
615
		
616 605
		return resultArea;
617 606
	}
618 607
	
......
622 611
	 * @return the default bottom toolbar of editors
623 612
	 */
624 613
	public TXMEditorToolBar getBottomToolbar() {
625
		
626 614
		return bottomToolBar;
627 615
	}
628 616
	
......
632 620
	 * @param colSpan
633 621
	 */
634 622
	public void initParentLayout(Composite parent, int colSpan) {
635
		
636 623
		GridLayout gl = GLComposite.createDefaultLayout(1);
637 624
		parent.setLayout(gl);
638 625
	}
......
644 631
	 * @return the extendedParametersGroup
645 632
	 */
646 633
	public Group getExtendedParametersGroup() {
647
		
648 634
		return this.extendedParametersGroup;
649 635
	}
650 636
	
651 637
	
652 638
	@Override
653 639
	public boolean isSaveAsAllowed() {
654
		
655 640
		// TODO Auto-generated method stub
656 641
		return false;
657 642
	}
......
687 672
	
688 673
	@Override
689 674
	public void dispose() {
690
		
691 675
		notifyExtensions("notifyDispose"); //$NON-NLS-1$
692 676
		super.dispose();
693 677
	}
......
700 684
	 * @param dirty
701 685
	 */
702 686
	public void setDirty(boolean dirty) {
703
		
704 687
		this.dirty = dirty;
705 688
		
706 689
		// FIXME: SJ: future version that enable the button ONLY if the result can compute
......
773 756
	@SuppressWarnings("unchecked")
774 757
	@Override
775 758
	public TXMResultEditorInput<T> getEditorInput() {
776
		
777 759
		return (TXMResultEditorInput<T>) super.getEditorInput();
778 760
	}
779 761
	
......
782 764
	 * 
783 765
	 * @return
784 766
	 */
767
	@Override
785 768
	public T getResult() {
786
		
787 769
		return this.getEditorInput().getResult();
788 770
	}
789 771
	
......
794 776
	 * @return
795 777
	 */
796 778
	public int getIntParameterValue(String key) {
797
		
798 779
		return this.getEditorInput().getResult().getIntParameterValue(key);
799 780
	}
800 781
	
......
805 786
	 * @return
806 787
	 */
807 788
	public float getFloatParameterValue(String key) {
808
		
809 789
		return this.getEditorInput().getResult().getFloatParameterValue(key);
810 790
	}
811 791
	
......
816 796
	 * @return
817 797
	 */
818 798
	public double getDoubleParameterValue(String key) {
819
		
820 799
		return this.getEditorInput().getResult().getDoubleParameterValue(key);
821 800
	}
822 801
	
......
827 806
	 * @return
828 807
	 */
829 808
	public boolean getBooleanParameterValue(String key) {
830
		
831 809
		return this.getEditorInput().getResult().getBooleanParameterValue(key);
832 810
	}
833 811
	
......
838 816
	 * @return
839 817
	 */
840 818
	public long getLongParameterValue(String key) {
841
		
842 819
		return this.getEditorInput().getResult().getLongParameterValue(key);
843 820
	}
844 821
	
......
849 826
	 * @return
850 827
	 */
851 828
	public String getStringParameterValue(String key) {
852
		
853 829
		return this.getEditorInput().getResult().getStringParameterValue(key);
854 830
	}
855 831
	
......
876 852
	 * @param result
877 853
	 * @param update force the editor to update its result parameters
878 854
	 */
855
	@Override
879 856
	public JobHandler compute(final boolean update) {
880 857
		
881 858
		StatusLine.setMessage(TXMCoreMessages.bind(TXMUIMessages.computing, this.getResult().getName()));
......
1112 1089
	 * @param editorPartId
1113 1090
	 */
1114 1091
	public static TXMEditor openEditor(TXMResult result, String editorPartId) {
1115
		
1116
		return openEditor(new TXMResultEditorInput<TXMResult>(result), editorPartId);
1092
		return openEditor(new TXMResultEditorInput<>(result), editorPartId);
1117 1093
	}
1118 1094
	
1119 1095
	/**
......
1170 1146
	 * @param update
1171 1147
	 * @throws Exception
1172 1148
	 */
1149
	@Override
1173 1150
	public final void refresh(boolean update) throws Exception {
1174 1151
		
1175 1152
		if (this.parent.isDisposed()) return; // nothing to refresh
......
1190 1167
		
1191 1168
		String title = result.getName();
1192 1169
		if (title.length() > MAX_NAME_LENGTH) { // limit title length
1193
			title = title.substring(0, MAX_NAME_LENGTH-1) + "...";
1170
			title = title.substring(0, MAX_NAME_LENGTH - 1) + "...";
1194 1171
		}
1195 1172
		this.setPartName(title);
1196 1173
		// this.firePropertyChange(TXMEditor.PROP_DIRTY);
......
1550 1527
	 */
1551 1528
	protected List<Field> getAllParameterFields() {
1552 1529
		
1553
		List<Field> fields = new ArrayList<Field>();
1530
		List<Field> fields = new ArrayList<>();
1554 1531
		Class<?> clazz = this.getClass();
1555 1532
		while (clazz != Object.class) {
1556 1533
			fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
......
1582 1559
	/**
1583 1560
	 * Closes the editor from the UI thread and deletes or not the linked result.
1584 1561
	 */
1562
	@Override
1585 1563
	public void close(final boolean deleteResult) {
1586 1564
		
1587 1565
		final EditorPart self = this;
......
1601 1579
	/**
1602 1580
	 * Closes the editor from the UI thread.
1603 1581
	 */
1582
	@Override
1604 1583
	public void close() {
1605
		
1606 1584
		close(false);
1607 1585
	}
1608 1586
	
......
1616 1594
	 * @return
1617 1595
	 */
1618 1596
	public static Menu initContextMenu(Composite composite, String menuId) {
1619
		
1620 1597
		return initContextMenu(composite, menuId, null, null);
1621 1598
	}
1622 1599
	
......
1632 1609
	 * @return
1633 1610
	 */
1634 1611
	public static Menu initContextMenu(Composite composite, IWorkbenchPartSite partSite, ISelectionProvider selectionProvider) {
1635
		
1636 1612
		return initContextMenu(composite, partSite.getId(), partSite, selectionProvider);
1637 1613
	}
1638 1614
	
......
1658 1634
			partSite.registerContextMenu(menuId, menuManager, selectionProvider);
1659 1635
		}
1660 1636
		else {
1661
			IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IMenuService.class);
1637
			IMenuService menuService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IMenuService.class);
1662 1638
			menuService.populateContributionManager(menuManager, "popup:" + menuId); //$NON-NLS-1$
1663 1639
		}
1664 1640
		
......
1672 1648
	 * @return the composite that contains the <b>default Top</b> TXMEditorToolBar parameters panels
1673 1649
	 */
1674 1650
	public GLComposite getParametersGroupsComposite() {
1675
		
1676 1651
		return extendedParametersComposite;
1677 1652
	}
1678 1653
	
......
1700 1675
	 * @param commandId
1701 1676
	 */
1702 1677
	public static void addDoubleClickCommandListener(final Table table, final int column, final String commandId) {
1703
		
1704 1678
		addDoubleClickCommandListener(table, column, column, commandId);
1705 1679
	}
1706 1680
	
......
1771 1745
	}
1772 1746
	
1773 1747
	
1748
	@Override
1774 1749
	public Composite getContainer() {
1775
		
1776 1750
		return parent;
1777 1751
	}
1778 1752
	
1753
	/**
1754
	 * Layouts the parent.
1755
	 */
1779 1756
	public void layout(boolean b) {
1780
		
1781 1757
		if (parent != null && !parent.isDisposed()) {
1782 1758
			parent.layout(b);
1783 1759
		}
......
1792 1768
	public void addLinkedEditor(final EditorPart editor) {
1793 1769
		
1794 1770
		if (this.linkedEditors == null) {
1795
			this.linkedEditors = new ArrayList<EditorPart>();
1771
			this.linkedEditors = new ArrayList<>();
1796 1772
		}
1797 1773
		if (!this.linkedEditors.contains(editor)) {
1798 1774
			this.linkedEditors.add(editor);
......
1849 1825
	 * @param editor
1850 1826
	 */
1851 1827
	public void removeLinkedEditor(EditorPart editor) {
1852
		
1853 1828
		if (this.linkedEditors != null) {
1854 1829
			if (this.linkedEditors.remove(editor)) {
1855 1830
				// Debug
......
1868 1843
	 * @return
1869 1844
	 */
1870 1845
	public ArrayList<EditorPart> getLinkedEditors() {
1871
		
1872 1846
		return this.linkedEditors;
1873 1847
	}
1874 1848
	
......
1879 1853
	 * @return
1880 1854
	 */
1881 1855
	public EditorPart getLinkedEditor(Class editorClass) {
1882
		
1883 1856
		EditorPart editor = null;
1884 1857
		if (this.linkedEditors != null) {
1885 1858
			for (int i = 0; i < this.linkedEditors.size(); i++) {
......
1899 1872
	 * @return
1900 1873
	 */
1901 1874
	public ArrayList<EditorPart> getLinkedEditors(Class editorClass) {
1902
		
1903
		ArrayList<EditorPart> editors = new ArrayList<EditorPart>();
1875
		ArrayList<EditorPart> editors = new ArrayList<>();
1904 1876
		if (this.linkedEditors != null) {
1905 1877
			for (int i = 0; i < this.linkedEditors.size(); i++) {
1906 1878
				if (this.linkedEditors.get(i).getClass().equals(editorClass)) {
......
1917 1889
	 * @return the computeButton
1918 1890
	 */
1919 1891
	protected ToolItem getComputeButton() {
1920
		
1921 1892
		return computeButton;
1922 1893
	}
1923 1894
	
......
1941 1912
	 * @return the parent
1942 1913
	 */
1943 1914
	public Composite getParent() {
1944
		
1945 1915
		return parent;
1946 1916
	}
1947 1917
	

Formats disponibles : Unified diff