⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lgprotegeprojectview.java

📁 protege在eclipse里的插件。安装之后就可以在eclipse里直接使用protege了
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		}
		public void interrupt() {
			if (!canceled)
				try {
					canceled = true;
					super.interrupt();
				} finally {
					destroy();
				}
		}
		public synchronized void run() {
			try {
				showLabelSync("");
				disposeAction.setEnabled(true);
				animatedMsg = new AnimatedMsgThread(MSG_OPENING);
				animatedMsg.start();
				// Reset the frame ...
				Frame sf = null;
				try {
					sf = getSwingFrame();
				} finally {
					animatedMsg.end();
				}
				// Display the result ...
				if (canceled || sf == null) {
					showLabelSync(MSG_INFO);
					disposeAction.setEnabled(false);
				} else {
					sf.setVisible(true);
					showSwingSync();			
				}
			} catch (Exception e) {
				disposeAction.setEnabled(false);
				Plugin.log(IStatus.ERROR,
					"An error occurred initializing the relation graph.", e);
			}
		}
	}

	/**
	 * Primary class ...
	 */
	static final private String MSG_INFO = "Select a Protege 2000 project (.pprj) file, then select the Open action (on the action bar of this view) to display Protege.";
	static final private String MSG_OPENING = "Opening the view ...";
	
	private Display display;
	private Composite displayArea, swtSwingContainer;
	private File projectFile = null;
	private SwingFrameAccess sfa;
	private SwingInitThread siThread;
	private Label label;
	private Action openAction, disposeAction, testAction;

	public LgProtegeProjectView() {
	}
	private void contributeToActionBars() {
		IActionBars bars = getViewSite().getActionBars();
		fillLocalPullDown(bars.getMenuManager());
		fillLocalToolBar(bars.getToolBarManager());
	}
	protected void createLabel() {
		label = new Label(displayArea, SWT.BORDER | SWT.WRAP);
	}
	protected void createLayout() {
		displayArea.setLayout(new StackLayout());
	}
	public void createPartControl(Composite parent) {
		display = parent.getDisplay();
		displayArea = parent;
		createLayout();
		createLabel();
		
		makeActions();
		contributeToActionBars();

		// Listen for changes in the Workbench selection.
		getViewSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
		// Display initial informational message.
		showLabel(MSG_INFO);
	}
	public void dispose() {
		disposeSwing();
		getViewSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this);
		if (label != null) label.dispose();
		super.dispose();
	}
	protected void disposeSwing() {
		disposeSwingThread();
		if (sfa != null)
			try { sfa.dispose(); }
				finally { sfa = null; }
	}
	protected void disposeSwingThread() {
		if (siThread != null)
			siThread.interrupt();
		siThread = null;
	}
	private void fillContextMenu(IMenuManager manager) {
		manager.add(openAction);
		manager.add(disposeAction);
		manager.add(new Separator());
		manager.add(testAction);
	}
	private void fillLocalPullDown(IMenuManager manager) {
		manager.add(openAction);
		manager.add(disposeAction);
		manager.add(new Separator());
		manager.add(testAction);
	}
	private void fillLocalToolBar(IToolBarManager manager) {
		manager.add(openAction);
		manager.add(disposeAction);
		manager.add(new Separator());
		manager.add(testAction);
	}
	protected Composite getSWTSwingContainer() {
		if (swtSwingContainer == null && display != null && !display.isDisposed())
			display.syncExec(new Runnable() {
				public void run() {
					swtSwingContainer = new Composite(displayArea, SWT.EMBEDDED);
				}
			});
		return swtSwingContainer;
	}
	protected Frame getSwingFrame() {
		if (sfa == null || sfa.isDisposed() && display != null && !display.isDisposed()) {
			sfa = new SwingFrameAccess();
			try {
				sfa.init();
			} catch (SwingInitException e) {
				Plugin.log(IStatus.ERROR,
					"An error occurred initializing the Swing frame.", e);
				sfa = null;
			}
		}
		return sfa != null ? sfa.getFrame() : null;
	}
	protected synchronized Thread getSwingInitThread() {
		if (!isSwingInitInProgress()) {
			siThread = new SwingInitThread();
			siThread.setName(getClass().getName());
		}
		return siThread;
	}
	protected boolean isSwingInitInProgress() {
		return siThread != null && siThread.isAlive();
	}
	protected void logInfo(String msg) {
		Plugin.log(IStatus.INFO, msg);
	}
	private void makeActions() {
		disposeAction = new Action() {
			public void run() {
				disposeSwing();
				disposeAction.setEnabled(false);
				showLabel(MSG_INFO);
			}
		};
		disposeAction.setEnabled(false);
		disposeAction.setText("Dispose");
		disposeAction.setToolTipText("Dispose the view");
		disposeAction.setImageDescriptor(Workbench.getInstance().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));

		openAction = new Action() {
			public void run() {
				disposeSwing();
				getSwingInitThread().start();
				openAction.setEnabled(false);
				disposeAction.setEnabled(true);
			}
		};
		openAction.setText("Open");
		openAction.setToolTipText("Open the view");
		openAction.setImageDescriptor(Workbench.getInstance().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OPEN_MARKER));
		openAction.setEnabled(false);

		testAction = new Action() {
			public void run() {
				if (sfa != null)
					try {
						sfa.pv.detachCurrentTab();
					} catch (Exception e) {
					}
			}
		};
		testAction.setText("Detach tab");
		testAction.setToolTipText("Detaches the currently selected tab");
		testAction.setImageDescriptor(LgProtegeI18n.getImageDescriptor("action_detach.gif"));
		testAction.setEnabled(true);
	}
	public void propertyChanged(Object source, int propId) {
	}
	public synchronized void selectionChanged(IWorkbenchPart part, final ISelection selection) {
		if (!disposeAction.isEnabled())
			try {
				// Process the selection ...
				if (!selection.isEmpty() && selection instanceof StructuredSelection) {
					Object o = ((StructuredSelection) selection).getFirstElement();
					if (o instanceof File && "pprj".equals(((File) o).getFileExtension()))
						projectFile = (File) o;
					else
						projectFile = null;
				}
			} catch (RuntimeException e) {
				// Failsafe for unexpected error; log & continue ...
				Plugin.log(IStatus.ERROR, 
					"An error occurred while processing the workbench selection.", e);
			} finally {
				openAction.setEnabled(projectFile != null);
			}
	}
	public void setFocus() {
	}
	protected void showSwing() {
		if (!displayArea.isDisposed()) {
			Composite swingContainer = getSWTSwingContainer();
			((StackLayout) displayArea.getLayout())
				.topControl = swingContainer;
			// Note: The following appears to help avoid a sporatic
			// repaint problem (controls are created but are
			// not initially visible).
			swingContainer.pack();
			swingContainer.layout();
			// Layout the controls ...
			displayArea.layout();
			readAndDispatch();
		}
	}
	protected void showSwingSync() {
		if (display != null && !display.isDisposed())
			display.syncExec(new Runnable() {
				public void run() {
					showSwing();
				}
			});
	}
	protected void showLabel(final String labelText) {
		if (!label.isDisposed()) {
			label.setText(labelText);
			((StackLayout) displayArea.getLayout()).topControl = label;
			displayArea.layout();
			readAndDispatch();
		}
	}
	protected void showLabelSync(final String labelText) {
		if (display != null && !display.isDisposed())
			display.syncExec(new Runnable() {
				public void run() {
					showLabel(labelText);
				}
			});
	}
	protected void readAndDispatch() {
		while (display != null && !display.isDisposed()
			&& display.readAndDispatch());
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -